In this post, we will provide a PowerShell script designed to perform system health checks on Windows servers. Regular health checks are crucial to ensure that your servers are running optimally and to identify potential issues before they escalate. This script will check CPU usage, memory usage, and disk space, providing a concise report of the system's status. By maintaining system health, you can enhance reliability and performance within your IT environment. Here is the PowerShell script to perform the health checks:
# Check CPU usage
$cpuUsage = Get-WmiObject -Class Win32_Processor | Measure-Object -Property LoadPercentage -Average
$cpuLoad = $cpuUsage.Average
# Check Memory usage
$mem = Get-WmiObject -Class Win32_OperatingSystem
$memUsage = [math]::round(($mem.TotalVisibleMemorySize - $mem.FreePhysicalMemory) / 1MB, 2)
# Check Disk space
$diskSpace = 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)}}, @{Name='Total(GB)';Expression={[math]::round($_.Used/1GB + $_.Free/1GB,2)}}
# Output report
Write-Host "CPU Load: $cpuLoad%"
Write-Host "Memory Usage: $memUsage MB"
$diskSpace | Format-Table -AutoSize
Write-Host "System health check completed."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.