System Health Check Script
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.
# 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."