Created
July 17, 2018 17:32
-
-
Save h3nryza/457fed2208e605ee7807b899536bbd29 to your computer and use it in GitHub Desktop.
Powershell get disk space
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
| $arrDisk = Get-WmiObject -class Win32_LogicalDisk | |
| foreach($Item in $arrDisk) | |
| { | |
| $Name = $Item.DeviceID | |
| $Caption = $item.VolumeName | |
| $PercentFree = [math]::round( ( ($item.FreeSpace /$item.Size)*100),2) | |
| $PercentUsed = [math]::round( (( $item.Size - $item.FreeSpace )/$item.Size)*100,2) | |
| $FreeSpace = [math]::round($item.FreeSpace/1gb,2) | |
| $UsedSpace = [math]::round(($item.Size/1gb - $item.FreeSpace/1gb ),2) | |
| $TotalSize = [math]::round($item.Size/1gb,2) | |
| write-host "Drive `t:$Name `nLabel `t:$Caption `n%Free `t:$PercentFree% `n%Used `t:$PercentUsed% `nFree `t:$FreeSpace GB `nUsed `t:$UsedSpace GB `nTotal `t:$TotalSize GB `n" | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment