Export a WMIObject to a csv
in our environment have bunch of computer trying figure out information on physical ram using get-wmiobject win32_physicalmemory. works great when there 1 stick of ram when use command
get-wmiobject win32_physicalmemory | select-object pscomputername, capacity, serialnumber, speed, manufacturer | export-csv "\\kisd-sccm01\g\reporting\reporting.csv"
but when there more 1 stick of ram export on 2 lines. i've tried figure out how can take sum of sticks capacity , output 1 row pscomputername, capacity, serialnumber, speed, manufacturer.
i've tried doing following exports sum
get-wmiobject win32_physicalmemory | select-object pscomputername, capacity, serialnumber, speed, manufacturer | measure-object -property capacity -sum | % {[math]::round(($_.sum / 1gb),2)} i've tried next code block , tried create variable $sum , pass export doesn't seem work either.
for way able sum of 2 capacity's , export on 1 line no matter how many sticks of ram present. in future may add more wmiobject's curious how output, example, above command win32_physicalmemory , some win32_processor information well.
thanks!!
it works when there 1 stick of ram if add -computername "name" , target computer 2 sticks of ram not add sum property , adds 2 lines in csv file.
since going add different wmi classes in future should take @ article.
they explain exact problem having right now. (making multiple objects / lines 1 object)
if find answer has helped please use answer button and/or use thumbs up! julio sanchez-tirado http://scriptomato.com co-founder | ceo | pitcher
Windows Server > Windows PowerShell
Comments
Post a Comment