PowerShell Query Help, WMI, Select Statement

Here is where I have started:

#Get Physical Memory 
function getwmiinfo ($svr) { 
 
 
gwmi -query "select * from 
     Win32_PhysicalMemory" -computername $svr | select [$svr], DeviceLocator  
 
} 
 
 
$Servers = get-content -path "C:\test.txt" 
 
 
foreach($Servers in $Servers) { 
 
 
 getwmiinfo $Servers 
 
} 



I get this:

[risk]                 DeviceLocator 
------                 ------------- 
                       DIMM0 
                       DIMM1 
What I want is this:

ServerName             DeviceLocator 
----------             ------------- 
RISK                   DIMM0 
RISK                   DIMM1 


Is this possible? How would I do it. I have spent hours on this and can't quite get it to work. Thanks!



Submitted via EggHeadCafe - Software Developer Portal of Choice 
Scrolling Div Tags to Create HTML Grid
http://www.eggheadcafe.com/tutorials/aspnet/e855b26e-dc01-4c6f-b560-3ee741e51512/scrolling-div-tags-to-cre.aspx
0
Brian
1/12/2010 8:33:32 PM
windows.powershell 690 articles. 0 followers. Follow

2 Replies
1331 Views

Similar Articles

[PageSpeed] 44

Try this for your select statement

.... | select @{name="ServerName";e={$svr}}, DeviceLocator

-Paul

"Brian Christofield" wrote:

> Here is where I have started:
> 
> #Get Physical Memory 
> function getwmiinfo ($svr) { 
>  
>  
> gwmi -query "select * from 
>      Win32_PhysicalMemory" -computername $svr | select [$svr], DeviceLocator  
>  
> } 
>  
>  
> $Servers = get-content -path "C:\test.txt" 
>  
>  
> foreach($Servers in $Servers) { 
>  
>  
>  getwmiinfo $Servers 
>  
> } 
> 
> 
> 
> I get this:
> 
> [risk]                 DeviceLocator 
> ------                 ------------- 
>                        DIMM0 
>                        DIMM1 
> What I want is this:
> 
> ServerName             DeviceLocator 
> ----------             ------------- 
> RISK                   DIMM0 
> RISK                   DIMM1 
> 
> 
> Is this possible? How would I do it. I have spent hours on this and can't quite get it to work. Thanks!
> 
> 
> 
> Submitted via EggHeadCafe - Software Developer Portal of Choice 
> Scrolling Div Tags to Create HTML Grid
> http://www.eggheadcafe.com/tutorials/aspnet/e855b26e-dc01-4c6f-b560-3ee741e51512/scrolling-div-tags-to-cre.aspx
> .
> 
0
Utf
1/12/2010 9:13:03 PM
On 12 Jan., 21:33, Brian Christofield wrote:
> Here is where I have started:
>
> #Get Physical Memory
> function getwmiinfo ($svr) {
>
> gwmi -query "select * from
> =A0 =A0 =A0Win32_PhysicalMemory" -computername $svr | select [$svr], Devi=
ceLocator =A0
>
> }
>
> $Servers =3D get-content -path "C:\test.txt"
>
> foreach($Servers in $Servers) {
>
> =A0getwmiinfo $Servers
>
> }
>
> I get this:
>
> [risk] =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 DeviceLocator
> ------ =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 -------------
> =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0DIMM0
> =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0DIMM1
> What I want is this:
>
> ServerName =A0 =A0 =A0 =A0 =A0 =A0 DeviceLocator
> ---------- =A0 =A0 =A0 =A0 =A0 =A0 -------------
> RISK =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 DIMM0
> RISK =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 DIMM1
>
> Is this possible? How would I do it. I have spent hours on this and can't=
 quite get it to work. Thanks!
>
> Submitted via EggHeadCafe - Software Developer Portal of Choice
> Scrolling Div Tags to Create HTML Gridhttp://www.eggheadcafe.com/tutorial=
s/aspnet/e855b26e-dc01-4c6f-b560-3...

Hi,
Change the Select Statement as follows:

select @{label=3D"ServerName";expression=3D{$_.__Server}}, DeviceLocator

Regards,
BJ
0
BJ
1/12/2010 9:26:37 PM
Reply:

Similar Artilces:

TRIM FUNCTION in QUERY
Hello, What do I put to trim off the spaces after a value in query? The table is obtained from ODBC link and the values on a field somehow got spaces. Example: My field in the query is: WC: PO_WORKCENTER_ID Not sure WC: TRIM(PO_WORKCENTER_ID) ???? That should work. -- Jerry Whittle, Microsoft Access MVP Light. Strong. Cheap. Pick two. Keith Bontrager - Bicycle Builder. "Cam" wrote: > Hello, > > What do I put to trim off the spaces after a value in query? The table is > obtained from ODBC link and the values on a field somehow got spaces. Example: > > My...

Button/Macro Not Working, Help!
I have a macro that pulls up Report Manager and prints out pre-define views. The macro works fine only after I use Report Manager the firs time. If I exit my workbook and Excel, then return to it, th button/macro does not function. Nothing happens until I manully us Report Manager again. Is there a bug with this or am I missin something -- Message posted from http://www.ExcelForum.com Post your code. Gord Dibben Excel MVP On Thu, 20 May 2004 08:38:55 -0500, baston <<baston.16k4at@excelforum-nospam.com>> wrote: >I have a macro that pulls up Report Manager and prints out pre...

Custom reports/queries across multiple companies in Business Porta
Is there any way to create a custom query or report that can be run inside Business Portal and which pulls figures from multiple Great Plains companies. Thank you. A View can be constructed in one database that pulls data from other databases. This view can then be used as the source for reports in tools like Crystal etc -- Richard L. Whaley Author / Consultant / MVP Documentation for Software Users Get our Free Tips and Tricks Newsletter and check out our books at http://www.AccoladePublications.com "KT" wrote: > Is there any way to create a custom query or report th...

query with inline dummy table
Is there a way in Access to create a query that contains the table records within the query itself? I want to avoid creating a dummy table and just use values within the query definition. I was thinking about using syntax similar to the insert into statement I would use to populate the dummy table, but I'm not sure if I have a syntax problem or I'm trying to solve an impossible problem. The query I'm thinking of might look something like this: select * from values("test"); -or- select * from ( ("1/1/07","2/1/07","3/1/07","4/1/07&qu...

Create form similar to MS Access 2000 Help
Is it possible to create a form that works similar to the Help - Index form in Access 2000? My StreetTable consists of the following fields: Street_ID(autonumber), StreetName(text), Directions(memo). I want to be able to type the beginning letters of the street and the List of StreetNames continually reduces until I see the street I need in the StreetNames window. I would then click on that street and the Directions would appear in the third window panel. Since I'm dealing with approx. 5000 streets, scrolling really isn't an option that I want to consider. I found that a combo ...

HELP: Excel userform version control issue
Hi All, I have an excel userform that is posted on my companys intranet. The issue I am having is, users are saving this form to their hard drive and then using it(Instead of launching it everytime from intranet), SO basically when I have a new version of form on intranet they still use the old version as they have a habbit of saving it on their hard drive. Is there a way to resove this? something like they would see a popup message saying that "This is an older version that you are using, Please launch the form from Intranet for newer version". Thanks in advan...

data validation
Is it possible to create a similar function like data validation, from which I can select multiple options? (Background: I need a list of many names, from which I case by case can select). Not really. Maybe you could use a listbox. I added a listbox from the Forms toolbar to a worksheet. I called it "List Box 1". I rightclicked on that listbox and chose Format Control. On the Control tab, I chose Selection Type of Multi. I also pointed at the range that held the values that go in that listbox. Then I added a button from the Forms toolbar (I click the button when I'm d...

Outlook attachment problems
Dear Our oversea office sender using Outlook Sending message (HTML) insert a picture sending message to my office, when I have received the attachment auto duplicate one set in the message. I have asked the sender try remove the picture and FORWARD to my e-mail, but the attachment sill in the message and auto duplicate one set attachment. Out overseas office using MS SBS , user setup WG mode for outlook download message. I am not sure which part problems or virus effect. Please advice how to solve out the problems ASAP. JACKIE ...

Multiple IF statement not working
I have numbers in cells b2, d2,e2, and f2. I am trying to write statment that will increment number in cell b2 by one for each cell (d2, e2, f2) that is greater than or equal to one. The following formula will not work if more than one cell (d2, e2, f2) has a zero in it: =IF(AND(D2>=1,E2>=1,F2>=1),B2+3,IF(OR(D2=0,E2=0,F2=0),B2+2,IF(AND (D2=0,E2=0),B2+1,IF(AND(D2=0,F2=0),B2+1,IF(AND(E2=0,F2=0),B2+1,))))) Does anyone know why? Try this =B2+COUNTIF(D2:F2,">=1") -- Wag more, bark less "Anthony" wrote: > I have numbers in cells b2, d...

Help with
I am currently in the process of migrating exchange 2000 to exchange 2003 on new hardware. I have transfered the RUS role, offline address book role and replicated the public folders ect. and now am beginning to move maiboxes. I noticed 3 very repetive errors in the application event log however. I was wondering if someone could tell me whether these messages are somthing I should be concerned with. See them below. So far I have no user complaints about outlook. Thanks. Event ID: 9320 Source MSExchangeSA Type Warning Description OALGen could not generate full details for some en...

Help with Inbox repair tool please
I have a problem with my outlook 2000 and have been advised to use the inbox repair tool. I have opened the inbox repair tool, and I am asked to enter the folder name or to browse and enter the location of the folder, I need to enter the delete items folder but do not know where to find it. Any help appreciated. John The Inbox Repair Tool works against Personal Folders Files (.PST files), not against individual folders within the .PST file. If you don't know where your .PST file is located, you can find it this way: In Outlook, make sure the Folder List is visible (View | Folder...

Help; how do i change the waiting circle (in IE tab) to anything e
I am making a website and i have a lot of wait time for my server-side pages to do their work. The waiting circle icon gives me a headache so I would like to change that to something else please. I remember IE6 had a great Microsoft Flag logo that would wave while a page would load. Could I get IE8 to use this logo? Sorry Trozza, you can't. "Trozza Mited" <Trozza Mited@discussions.microsoft.com> wrote in message news:9C401644-2391-4317-92BD-D7F3DFD2B06C@microsoft.com... > I am making a website and i have a lot of wait time for my server-side > p...

Free shipping for selected customers
Our Store Ops system is setup to always charge shipping on all orders for all customers (the "Automatic shipping" option in Store Ops configuration is checked). For 99% of our customers, this is correct. However, there are a select group of employees who work in our warehouse. They do not need the garments shipped to them, so they should not automatically be charged shipping. There are also some high-end customers who we normally provide free shipping as a courtesy. Our system is also setup to received orders from a website (using a custom web interface). It can feed the cu...

Help With Problem: Nested IF Function, Office2K v Office2003
Hello Group, I'm looking for some help with a nested IF worksheet function. Shown below is a formula that I'm using in a model. =SUM(IF(worksheet!$A$3:$A$54=DATEVALUE("9/1/2005"),IF(worksheet!$B$3:$B$54="<90",worksheet!$C$3:$C$54,0),0)) If short, what I'm trying to do is scan the data in two columns and for any cells which meet the TRUE case in both columns, then sum the third numbers for all cases returning TRUE-TRUE. If either cell returns a FALSE, then enter 0. I created the original formulas and model in Office2000 and have used the model for more tha...

Options Group and Query Criteria, revisited
I recently posted a question about option groups passing info to a query for a Yes/No field, and received some great advice. However, I've tried to apply that advice in a similar way to a Date field, to no avail. In the query, I want the user to be able to display (1) only records with dates present or (2) only records without dates present or (3) all records. I changed the query criterion that worked for the checkbox as follows, and placed it under the Date field which I want to select by (this statement yields no records): IIF([forms].[fmQryByClinicSurveys].[emailOptions]=1...

Please help with New Database Query
Newbie to New Database Query - Can you change a spreadsheet to a table if so how? I have a lot of spreadsheets that I would like to work with in New Database Query. Can this be done. Any help will be greatly appreciated. In general, if you select a range and give it a name....MS Query will recognize it as a data source: Example for data in Cells A1:Z500, with column headings (EmpID, FName, Lname, etc): Select A1:Z500 In the Names box (just above the Col_A heading) type rngMyData1 Press [Enter] Next, save your workbook. Then...Data>Import External Data>New Database Query When y...

Spreadsheet Query
One of my clients has devised a list of items in a Microsoft Excel spreadsheet. Against each item (in a different cell) is an amount in �, which represtents the items value. My client wants to be able to use this spreadsheet, so that he can select all items under �6,000 for example. Is this possible in Excel, or should he be using a database ? Any suggestions would be appreciated. Michael. Hi Michael click in the list, choose data / filter / autofilter from the drop down list on the value column choose custom set the first box to less than and type 6000 in the second - click OK - to...

Skip Query Parameter
Dear All I Have a combo box that is feeding a query parameter to filter some rows. sometimes I want to view all records. the row source for this combo box is a table assigned only for that. and I want to add this option to be displayed in the combo box "View All". So I will add a new record in that table that will have the value of "View All" then the filter will not work. how can i solve it ? The data type in this combo box is "text". and I have similar case for "Date" Data type in text box. Thanks -- M.A.Halim mmhalim@hotmail.com Dear "M.A....

MS Query help required
Hi I have a spreadsheet on my notebook which I use for DBA services at a particular client. It connects to database server via an existing ODBC database connection extracting data from system tables. I would like to be able use this spreadsheet at other clients, WITHOUT having to create a new ODBC connection. Is there any way that this can be accomplished? The ideal scenario would be that the logon credentials and server address reside on one sheet and upon arrival at another client, one merely changes this information and then queries the database. Any help would be appreciated. Regards -...

opencurrentdatabase error/help
dears, im opening an access03 database with vb6 like application.opencurrentdatabase("c:/documents and settings/admin/folder/database.mdb",true,"password") application.docmd.open"myform" application.docmd.maximise docmd.maximise included in form open event also in the database kindly help me with (1) after this code runs access opening with small rectangular window(half of screen vertically) even all access databases are opening this way (2) if the above said path changes for the database error 7866 occuring in error event i would like to include some c...

Need help with a formula 01-23-10
I am looking for a formula that will compute an average of a number of non contiguous cells such as G8, G16, G24, G36, etc. Each of these cells has a formula which computes an average of a range of cells. With the helpm of this forum, I have been able to find a formula which does that AND uses values only when they are greater than zero and does not display #DIV/0!. But I cannot fin a fromula that will do the next step- Take an average of those specific cells AND use only the ones where the cell is >0, Example G8=100, G16=85, G24 is blank, G36=75, then this formula would ca...

How to keep the application even when show desktop is selected
Hi, I am developing an application which is a sort of reminder of your daily tasks. I want this application to remain on the top right corner of desktop even when "show desktop" is selected. However it gets minimised.........Any helps appreciated. Perhaps you want to consider "Active Channel Technology" and making your display part of the "Active Desktop"? In article <D580FA88-9C89-4D3F-AB9A-8374A9DE266B@microsoft.com>, Katiyar@discussions.microsoft.com says... > Hi, > I am developing an application which is a sort of reminder of your dail...

IF problems, PLEASE HELP!!!
Hello, I am having trouble with "IF" I need to be able to say: IF E4 is 0-550: "start up"; 551-650: "moderate";651-850: "gettin there"; >850: "got there" How do I write this as a forumla? Let Me Know -- ryangruh ----------------------------------------------------------------------- ryangruhn's Profile: http://www.excelforum.com/member.php?action=getinfo&userid=1603 View this thread: http://www.excelforum.com/showthread.php?threadid=27497 try this dude! =if(and(e4>=0,e4<=550),"start up",if(and(e4>=551,e4...

help me understand excel!!!!!!!!!!!!!!
My job needs input info.... plzzzzzzz if you can help........... Help you how? CountryGirl Wrote: > My job needs input info.... plzzzzzzz if you can help.......... -- BenjieLo ----------------------------------------------------------------------- BenjieLop's Profile: http://www.excelforum.com/member.php?action=getinfo&userid=1101 View this thread: http://www.excelforum.com/showthread.php?threadid=27035 you need to be more specific, what are you trying to do ? bobf "CountryGirl" wrote: > My job needs input info.... plzzzzzzz if you can help.....

player closes if video category selected
I am running media player 11.0.5721.5268 on a XP home edition SP2 and whenever I choose the video category it appears briefly and then media player closes. Any help would be appreciated. In WMP,open tools,options,"file types tab",locate the button "select all" apply,maybe edit the other tabs as well. "master_samuri" wrote: > I am running media player 11.0.5721.5268 on a XP home edition SP2 and > whenever I choose the video category it appears briefly and then media player > closes. Any help would be appreciated. That sounds like a ...