System Resource Usage Report

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.

$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"