← script library

System Health Check Script

Monitoring & HealthDecember 27, 2024

This PowerShell script conducts a comprehensive health check of your Windows system to ensure everything is functioning optimally. By automating this process, system administrators can quickly identify potential issues related to hardware, software, and system configurations. Integrating this script with ServerEngine enhances your server management efficiency, making it easier to achieve proactive maintenance and avoid downtime.

powershell
# Get CPU Usage
$cpu = Get-WmiObject Win32_Processor | Measure-Object -Property LoadPercentage -Average | Select-Object -ExpandProperty Average
# Get Memory Usage
$mem = Get-WmiObject Win32_OperatingSystem
$totalMemory = [math]::round($mem.TotalVisibleMemorySize / 1MB, 2)
$freeMemory = [math]::round($mem.FreePhysicalMemory / 1MB, 2)
$usedMemory = [math]::round($totalMemory - $freeMemory, 2)
$memoryUsage = [math]::round(($usedMemory / $totalMemory) * 100, 2)
# Get Disk Space
$disk = Get-PSDrive C
$diskUsage = [math]::round(($disk.Used / $disk.Total) * 100, 2)
# Output Summary
$report = @"
System Health Check Report:
---------------------------
CPU Usage: $cpu%
Memory Usage: $memoryUsage%
Disk Usage: $diskUsage% (C Drive)
"@
# Save report to a text file
$report | Out-File -FilePath "C:\SystemHealthCheck.txt"
Write-Output "System health check report has been generated at C:\SystemHealthCheck.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.