PowerShell
public
Windows Volume Health
Share this script safely, inspect its metadata, and copy the exact command you need.
Ready to run
One-liner
curl -fsSL https://runny.sh/r/5YTMA117YWNJ | pwsh
Current version: 1.1 · Updated by Godmode · 2026-09-07 02:38:59.549
At a glance
Script metadata
Readable before runnable
Preview
# Windows volume health
# Read-only: Get-Volume free space. Warns below 15% free, critical below 5%.
# Exit 0 if current, 1 if a volume is low, 2 on error.
# Hosted on Runny.sh. Review the script page before you run it.
$ErrorActionPreference = 'Continue'
$status = 0
$warns = 0
$crits = 0
function Write-Line {
param([string]$Text)
Write-Output $Text
}
function Set-Warn {
if ($script:status -lt 1) { $script:status = 1 }
}
function Set-Crit { $script:status = 2 }
Write-Line '=== Windows volume free space ==='
Write-Line ("Host: {0}" -f $env:COMPUTERNAME)
Write-Line ''
try {
$volumes = @(Get-Volume -ErrorAction Stop | Where-Object { $_.Size -and $_.Size -gt 0 })
} catch {
Write-Line 'Get-Volume failed'
Write-Line $_.Exception.Message
Write-Line 'Result: ERROR'
exit 2
}
if ($volumes.Count -eq 0) {
Write-Line 'No volumes with a reported size'
Set-Warn
}
foreach ($vol in $volumes) {
$letter = if ($vol.DriveLetter) { "$($vol.DriveLetter):" } else { '(no letter)' }
$label = if ($vol.FileSystemLabel) { $vol.FileSystemLabel } else { $vol.FileSystem }
$freePct = [math]::Round(($vol.SizeRemaining / $vol.Size) * 100, 1)
$freeGiB = [math]::Round($vol.SizeRemaining / 1GB, 2)
$sizeGiB = [math]::Round($vol.Size / 1GB, 2)
Write-Line (" {0} {1} {2}% free ({3} / {4} GiB)" -f $letter, $label, $freePct, $freeGiB, $sizeGiB)
if ($freePct -le 5) {
Write-Line ' CRITICAL: volume is nearly full'
$crits++
Set-Crit
} elseif ($freePct -le 15) {
Write-Line ' WARNING: free space is low'
$warns++
Set-Warn
}
}
Write-Line ''
if ($status -eq 0) {
Write-Line 'Result: CURRENT'
} elseif ($crits -gt 0) {
Write-Line ("Result: ACTION NEEDED ({0} critical, {1} warning)" -f $crits, $warns)
} else {
Write-Line ("Result: ACTION NEEDED ({0} low volume(s))" -f $warns)
}
exit $status
Raw endpointhttps://runny.sh/r/5YTMA117YWNJ
See something unsafe?
Report this script
Tell us why it should come down. Anyone can also report a URL at /abuse.