Listing mount point disk free space using PowerShell

Working for a customer who had no monitoring solution in place, I had to write a PowerShell script to administer the free disk space on disks attached via mount points.

get-wmiobject win32_volume|
select Name, Label, 
@{Name="Capacity (GB)";Expression={$_.Capacity/1GB}},
@{Name="FreeSpace";Expression= {$_.FreeSpace /1GB}},
@{Name="FreeSpace (%)";Expression={[math]::Round(($_.FreeSpace/$_.Capacity*100),0)}} |
format-table

Executing the above PS script we get the below result.

Name                    Label                             Capacity (GB)               FreeSpace         FreeSpace (%)
----                    -----                             -------------               ---------         ---------------
\\?\Volume{b0feb7ce-...                               0.341793060302734       0.104545593261719                      31
E:\                     Program Files                  558.877925872803        256.821830749512                      46
J:\AP_01\               AP_01                          249.997066497803        209.281085968018                      84
J:\AP_Logs\             AP_Logs                        149.997066497803        94.5126991271973                      63
J:\AP_Temp01\           AP_Temp01                      149.997066497803        122.869915008545                      82
J:\AP_Temp01Logs\       AP_Temp01Logs                  99.9970664978027        97.8714447021484                      98
I:\DB_01\               DB_01                          249.997066497803        194.739963531494                      78
I:\DB_Logs\             DB_Logs                        169.997066497803        116.469699859619                      69
I:\DB_Temp01\           DB_Temp01                      149.997066497803        141.869903564453                      95
I:\DB_Temp01Logs\       DB_Temp01Logs                  99.9970664978027        97.8714332580566                      98
M:\SW_01\               SW_01                          249.997066497803         221.81583404541                      89
M:\SW_Logs\             SW_Logs                        99.9970664978027         63.207633972168                      63
M:\SW_Temp01\           SW_Temp01                      149.997066497803        141.869911193848                      95
M:\SW_Temp01Logs\       SW_Temp01Logs                  99.9970664978027        97.8714447021484                      98

For more details on using the Get-WmiObject, you can refer to the Technet article.

Leave a Comment

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.

Scroll to Top