Reports size, used space and free space for every fixed volume on a host, and warns twice over: once when free space drops below a percentage, once when it drops below an absolute number of gigabytes. The second threshold is the one that matters on large volumes, where 5% free still means the log drive is about to stop a service. Both thresholds sit at the top of the script as parameters.
powershell
# Check Disk Space
# Single use case: report free space on all fixed volumes, warn below threshold
# Author: SENTRI AI Engine | Date: 2026.08.14
#-----------------------------------------------------------------
function Write-Log {
param(
[Parameter(Mandatory)]
[string]$Message,
[ValidateSet('INFO', 'WARN', 'ERROR', 'OK')]
[string]$Level = 'INFO'
)
$prefix = switch ($Level) {
'WARN' { '[WARN] ' }
'ERROR' { '[ERROR] ' }
'OK' { '[OK] ' }
default { '[INFO] ' }
}
Write-Host "<WRITE-LOG = `"*$prefix$Message*`">"
}
# --- Parameters (replace via ServerEngine API parameters if needed) ---
$WarnPercentFree = 15
$WarnAbsoluteGB = 5.0 # Also warn if less than this many GB are free, regardless of percentage
$volumes = Get-CimInstance -ClassName Win32_LogicalDisk -Filter "DriveType=3" -ErrorAction SilentlyContinue
if (-not $volumes) {
Write-Log "No fixed volumes found!" -Level ERROR
return
}
$warnings = 0
$hostname = $env:COMPUTERNAME
Write-Log "================ Disk Space Report — $hostname ================"
foreach ($v in $volumes) {
if ($v.Size -eq 0) { continue }
$freeGB = [math]::Round($v.FreeSpace / 1GB, 2)
$sizeGB = [math]::Round($v.Size / 1GB, 2)
$usedGB = [math]::Round(($v.Size - $v.FreeSpace) / 1GB, 2)
$freePct = [math]::Round(($v.FreeSpace / $v.Size) * 100, 1)
$belowPercent = $freePct -lt [double]$WarnPercentFree
$belowAbsolute = $freeGB -lt $WarnAbsoluteGB
if ($belowPercent -or $belowAbsolute) {
$reasons = @()
if ($belowPercent) { $reasons += "free space $freePct% below ${WarnPercentFree}% threshold" }
if ($belowAbsolute) { $reasons += "absolute free space ${freeGB} GB below ${WarnAbsoluteGB} GB minimum" }
Write-Log "WARNING: [$($v.DeviceID)] $freeGB GB free of $sizeGB GB (${usedGB} GB used, $freePct% free) — $($reasons -join '; ')" -Level WARN
$warnings++
} else {
Write-Log "OK: [$($v.DeviceID)] $freeGB GB free of $sizeGB GB ($freePct% free)" -Level OK
}
}
Write-Log "Disk space scan complete: $warnings volume(s) flagged." -Level $(if ($warnings -gt 0) { 'WARN' } else { 'OK' })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 Checks & Diagnostics
Check and Restart a Windows Service with PowerShell
2026-08-17Check CPU Usage with PowerShell
2026-08-17Check RAM Usage with PowerShell
2026-08-17Check Server Uptime with PowerShell
2026-08-17Check for a Pending Reboot with PowerShell
2026-08-17Check NTP Time Sync and Clock Offset with PowerShell
2026-08-17Ready when you are.
Try ServerEngine free for 7 days.