Wednesday, June 5, 2013

powershell script to get number of CPU and Memory

takes input list of servers from C:\servers.txt and output the result to C:\ram-cpu.csv

make sure your powershell/powerCLI has admin rights


get-wmiobject Win32_ComputerSystem -computer (gc C:\servers.txt) | select Name,@{name="TotalPhysicalMemory(MB)";expression={($_.TotalPhysicalMemory/1mb).tostring("N0")}},NumberOfProcessors | export-csv C:\ram-cpu.csv

2 comments:

  1. get-wmiobject Win32_ComputerSystem -computer (gc C:\script\servers.txt) | select Name,@{name="TotalPhysicalMemory(MB)";expression={($_.TotalPhysicalMemory/1mb).tostring("N0")}},NumberOfProcessors,NumberOfLogicalProcessors | export-csv C:\ram-cpu.csv

    ReplyDelete