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!

JasonMArcher
  • 14,195
  • 22
  • 56
  • 52
Brian
  • 1

1 Answers1

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
TravisEz13
  • 2,263
  • 1
  • 20
  • 28
John Weldon
  • 39,849
  • 11
  • 94
  • 127