Quantcast
Channel: Windows PowerShell forum
Viewing all articles
Browse latest Browse all 21975

combine two get wmi-object commands in one script

$
0
0

Hello I had no luck searching for this on line, and was hoping someone could help me out. Its probably something syntax im missing but , im trying to get Two different WMI info in one script. the script pulls from a csv file. how ever when ever I run it only the first command runs. individually they each run fine.

$testcsv = import-csv c:\tools\pstools\memorytest.csv


  foreach($arg in $testcsv)
{
   $servername = $arg.servername 
Get-WmiObject win32_computersystem -computer $servername | Select-Object name
Get-WMIObject -class Win32_PhysicalMemory -computer $servername | Measure-Object -Property capacity -Sum | select @{N="Total Physical Ram"; E={[math]::round(($_.Sum / 1GB),2)}}
}

- not sure what separator im supposed to use if any, im not piping one into another I want both results displayed.

If someone could help that would be greatly appreciated,

-Eli


Viewing all articles
Browse latest Browse all 21975

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>