Created
September 23, 2023 13:58
-
-
Save rossarioking/6a786e84a340b0c34cc5a850a0848b3d to your computer and use it in GitHub Desktop.
Monitoring Disk Space with Powershell
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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