Input :
Save the list of servers in >>>>>>>>>>>> c:\servers.txt
Output :
Results will be saved at >>>>>>>>>>>>>>> C:\new\report.csv
Powershell script
###############################################################
GC C:\Servers.txt | % {
$Comp = $_
If (Test-Connection $Comp -Quiet){
$Mem = GWMI -Class win32_operatingsystem -computername $COMP
New-Object PSObject -Property @{
Server = $Comp
"CPU usage" = "$((GWMI -ComputerName $COMP win32_processor | Measure-Object -property LoadPercentage -Average).Average) %"
"Memory usage" = "$("{0:N2}" -f ((($Mem.TotalVisibleMemorySize - $Mem.FreePhysicalMemory)*100)/ $Mem.TotalVisibleMemorySize)) %"
"Total FreeSpace" = "$("{0:N2}" -f ((Get-WmiObject -Class win32_Volume -ComputerName $COMP -Filter "DriveType = '3'" | Measure-Object -property FreeSpace -Sum).Sum /1GB)) GB"
}
}
Else{
"" | Select @{N="Server";E={$Comp}},"CPU usage","Memory usage","Total FreeSpace"
}
}| Select Server,"CPU usage","Memory usage","Total FreeSpace" |
Export-Csv C:\new\report.csv -nti
#######################################################################