Skip to content

Instantly share code, notes, and snippets.

@rossarioking
Created September 23, 2023 13:58
Show Gist options
  • Save rossarioking/6a786e84a340b0c34cc5a850a0848b3d to your computer and use it in GitHub Desktop.
Save rossarioking/6a786e84a340b0c34cc5a850a0848b3d to your computer and use it in GitHub Desktop.
Monitoring Disk Space with Powershell
Get-WmiObject Win32_LogicalDisk | Where-Object { $_.DriveType -eq 3 } | ForEach-Object {
$disk = $_
$freeSpace = [math]::Round($disk.FreeSpace / 1GB, 2)
$totalSpace = [math]::Round($disk.Size / 1GB, 2)
Write-Host "$($disk.DeviceID) - Free Space: ${freeSpace}GB / Total Space: ${totalSpace}GB"
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment