PowerShell for Windows Admins

Jan 30 2019   11:09AM GMT

Get-DiskSpace

Richard Siddaway Richard Siddaway Profile: Richard Siddaway

Tags:
Powershell

The Get-DiskSpace cmdlet from the NTFSsecurity module is useful in that it gives ready calculated percentages of free and used space:

AvailableFreeSpacePercent  : 56.73%
AvailableFreeSpaceUnitSize : 270.11 GB
ClusterSize                : 4096
DriveName                  : \\?\Volume{c1c4c5bb-0000-0000-0000-f01500000000}\
TotalSizeUnitSize          : 476.1 GB
UsedSpacePercent           : 43.27%
UsedSpaceUnitSize          : 206 GB
FreeBytesAvailable         : 290024239104
TotalNumberOfBytes         : 511210610688
TotalNumberOfFreeBytes     : 290024239104
BytesPerSector             : 512
NumberOfFreeClusters       : 70806699
SectorsPerCluster          : 8
TotalNumberOfClusters      : 124807278

BUT as you can see it doesn’t identify the Drive Name by user friendly name.

You can do

PS> Get-DiskSpace -DriveLetter C:

AvailableFreeSpacePercent  : 56.73%
AvailableFreeSpaceUnitSize : 270.1 GB
ClusterSize                : 4096
DriveName                  : C:\
TotalSizeUnitSize          : 476.1 GB
UsedSpacePercent           : 43.27%
UsedSpaceUnitSize          : 206 GB
FreeBytesAvailable         : 290020270080
TotalNumberOfBytes         : 511210610688
TotalNumberOfFreeBytes     : 290020270080
BytesPerSector             : 512
NumberOfFreeClusters       : 70805730
SectorsPerCluster          : 8
TotalNumberOfClusters      : 124807278

but that means passing each drive separately. The DriveLetter parameter should take an array of drives according to the syntax diagram but that doesn’t seem to work.

Try running something like

Get-Volume |
where DriveLetter |
sort Driveletter |
foreach {
Get-DiskSpace -DriveLetter “$($_.Driveletter):” |
select DriveName, TotalSizeUnitSize, UsedSpaceUnitSize,
AvailableFreeSpaceUnitSize, UsedSpacePercent, AvailableFreeSpacePercent
}

and you get a nice output

DriveName                  : C:\
TotalSizeUnitSize          : 476.1 GB
UsedSpaceUnitSize          : 206 GB
AvailableFreeSpaceUnitSize : 270.1 GB
UsedSpacePercent           : 43.27%
AvailableFreeSpacePercent  : 56.73%

 Comment on this Post

 
There was an error processing your information. Please try again later.
Thanks. We'll let you know when a new response is added.
Send me notifications when other members comment.

Forgot Password

No problem! Submit your e-mail address below. We'll send you an e-mail containing your password.

Your password has been sent to:

Share this item with your network: