0

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!

4

1 に答える 1

0

replace [$svr] with ServerName, because [$svr] isn't a field you can select.

Also, I'd change

foreach($Servers in $Servers) {


 getwmiinfo $Servers

}

to

foreach($Server in $Servers) {
 getwmiinfo $Server
}

Notice the variable name change in the foreach statement

Update

gwmi -query "select * from Win32_PhysicalMemory" | select __SERVER, DeviceLocator
于 2010-01-12T20:31:34.723 に答える