Server Performance Reporting.txt - Notepad

Server Performance Reporting

The below powershell script reports on a server's CPU utilistaion over three two second periods, available RAM in MBytes, and Hard Disk space utilistation. It then emails the result. It is designed to be run as a scheduled task.
write-output "CPU utilisation" | out-file c:\results.txt
Get-Counter -Counter "\Processor(_Total)\% Processor Time" -SampleInterval 2 -MaxSamples 3 | format-table -auto | out-file c:\results.txt -append

write-output "Available RAM" | out-file c:\results.txt -append
Get-Counter '\Memory\Available MBytes' | format-table -auto | out-file c:\results.txt -append

write-output "Hard disk utilisation" | out-file c:\results.txt -append
Get-WMIObject Win32_LogicalDisk -filter "DriveType=3" | Select SystemName,DeviceID,VolumeName,@{Name="size(GB)"; Expression={"{0:N1}" -f($_.size/1gb)}},@{Name="freespace(GB)";Expression={"{0:N1}" -f($_.freespace/1gb)}} | out-file c:\results.txt -append

$nickbeare = get-content c:\results.txt | out-string

send-mailmessage -to "Nick <&recipient@nickbeare.com>" -from "mail <&sender@nickbeare.com>" -body $nickbeare -subject "Mail Server Utilisation" -smtpserver WIN-MAIL

Back