← script library

System Resource Usage Report

Monitoring & HealthDecember 27, 2024

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.

Ready when you are.

Try ServerEngine free for 7 days.