PowerShell
Low risk
Check available disk space on Windows
Lists local volumes and calculates their occupancy rate to quickly identify a saturated disk.
Get-Volume | Where-Object DriveLetter | ForEach-Object {
$Used = $_.Size - $_.SizeRemaining
[PSCustomObject]@{
Lecteur = $_.DriveLetter
Name = $_.FileSystemLabel
Taille_Go = [math]::Round($_.Size / 1GB, 1)
Utilise_Go = [math]::Round($Used / 1GB, 1)
Libre_Go = [math]::Round($_.SizeRemaining / 1GB, 1)
Occupation_Pc = if ($_.Size) { [math]::Round(($Used / $_.Size) * 100, 1) } else { 0 }
}
} | Sort-Object Occupation_Pc -Descending | Format-Table -AutoSize
When should you use it?
Run this before an update, when a server becomes slow, or when a backup fails because of insufficient space.
What the script does
- The command calculates used space from total capacity and remaining free space.
- The fullest volumes are displayed first.
Precautions
- This command does not delete any files.
- A volume above 90% usage usually deserves further investigation.
Rollback
No rollback is required.