IT / Desktop Support Project
System Health Report — a PowerShell Diagnostic Script
The Goal
I wanted hands-on practice with PowerShell and the CIM/WMI classes that underpin a lot of real Windows administration, so I built a script that gathers the checks a helpdesk tech would normally run by hand — uptime, CPU load, memory usage, disk space, recent system errors, and the processes eating the most resources — and writes them all into one timestamped report.
How It Works
Get-SystemHealthReport.ps1 is organized as a set of small functions, each responsible for one section of the report, called in sequence and captured to a text file with Start-Transcript:
- System Info — hostname, OS version/build, and uptime since last boot, pulled from
Win32_OperatingSystemandWin32_ComputerSystemviaGet-CimInstance. - CPU — processor model and current load percentage from
Win32_Processor. - RAM — total, used, and percent-used memory, calculated from
TotalVisibleMemorySizeandFreePhysicalMemory. - Disks — capacity and free space per volume, with anything under 15% free flagged with a "LOW SPACE" warning.
- Recent Errors — the last 5 Error/Critical entries from the System event log via
Get-WinEvent. - Top Processes — the top 5 processes by cumulative CPU time and by working-set memory.
The disk-space check was the part I spent the most time on — flagging low space automatically instead of just listing raw numbers felt closer to what an actual monitoring script should do:
function Get-DiskSection {
$volumes = Get-Volume | Where-Object { $_.DriveLetter }
foreach ($vol in $volumes) {
$sizeGB = $vol.Size / 1GB
$freeGB = $vol.SizeRemaining / 1GB
$percentFree = ($freeGB / $sizeGB) * 100
[PSCustomObject]@{
Drive = $vol.DriveLetter
SizeGB = [math]::Round($sizeGB, 2)
FreeGB = [math]::Round($freeGB, 2)
PercentFree = [math]::Round($percentFree, 1)
Warning = if ($percentFree -lt 15) { "LOW SPACE" } else { "" }
}
}
}
Sample Output
Run against my own laptop, the script produces a report like this (trimmed for length):
===== SYSTEM INFO =====
Hostname : LAPTOP-HELLA79T
OSVersion : Microsoft Windows 11 Home
Build : 26200
LastBoot : 7/15/2026 10:27:42 AM
Uptime : 0d 0h 4m
===== CPU =====
Model : Intel(R) Core(TM) i5-1035G1 CPU @ 1.00GHz
UtilizationPercent : 56
===== RAM =====
TotalGB : 11.75
UsedGB : 6.98
PercentUsed : 59.4
===== DISKS =====
Drive SizeGB FreeGB PercentFree Warning
----- ------ ------ ----------- -------
C 929.95 809.76 87.1
D 929.95 850.72 91.5
===== TOP 5 BY MEMORY =====
Name Id MemoryMB
---- -- --------
Code 16456 574.69
Code 13096 413.25
MsMpEng 4968 403.7
firefox 9244 374.92
firefox 11572 322.27
What I'd Add Next
- A
-ComputerNameparameter and CIM sessions to run the report against remote machines instead of just locally. - Export to HTML or CSV so a report is easier to skim or attach to a ticket.
- Wrap it as a scheduled task to capture recurring health snapshots over time instead of a single point-in-time run.