This PowerShell script generates a detailed report of the system resource usage, including CPU, memory, and disk space. This can be invaluable for system administrators who need to keep track of performance metrics, particularly when managing servers using solutions like ServerEngine. By running this script, users can quickly assess the health and efficiency of their systems and make informed decisions about resource allocation.
powershell
$cpuUsage = Get-Counter '\Processor(_Total)\% Processor Time'
$memUsage = Get-Counter '\Memory\Available MBytes'
$diskUsage = Get-PSDrive -PSProvider FileSystem | Select-Object Name, @{Name="Used(GB)";Expression={[math]::round($_.Used/1GB,2)}}, @{Name="Free(GB)";Expression={[math]::round($_.Free/1GB,2)}}
$report = @()
$report += "CPU Usage: " + $cpuUsage.CounterSamples.CookedValue + "%"
$report += "Available Memory: " + $memUsage.CounterSamples.CookedValue + " MB"
$diskUsage | ForEach-Object {
$report += "$($_.Name) - Used: $($_.'Used(GB)') GB, Free: $($_.'Free(GB)') GB"
}
$report | Out-File -FilePath "C:\SystemResourceReport.txt"
Write-Output "Resource usage report generated at C:\SystemResourceReport.txt"Run it across your fleet
This script runs as-is on a single host. Paste it into ServerEngine to schedule it, run it on a whole server group in parallel, and keep the credentials out of the file — see the scripts documentation and the credential store.
More in Monitoring & Health
Disk Space Cleanup and Report Script
2025-01-14User Account Status Reporting Script
2025-01-13Automated Disk Space Monitoring Script
2025-01-13Monitor System Performance with PowerShell
2025-01-12Automating System Health Check with PowerShell
2025-01-05Automate System Performance Monitoring with PowerShell
2024-12-30Ready when you are.
Try ServerEngine free for 7 days.