Digital Nervous System Making Incredible Software, Incredibly Simple

CSV Volume Free Space

Working with Mounted file systems is cool; but there is one real pain, how do you quickly find out your remaining capacity?

WMI of course, but gosh do I really want to, or need to do that… Yes and its really simple with PowerShell, Just look

Get-WmiObject
Win32_Volume | Select Name, Capacity, FreeSpace, FileSystem | **FT
**

This one command will tell us all we need to know, but it’s reporting in Bytes, and not very easy read, so with a little formatting on the data we get back, this can look a lot better, and much easier read

Get-WmiObject
Win32Volume | Select Name, @{Name=”Size(GB)”; Expression={“{0:N2}”
-f ($
.Capacity/1GB)}},@{Name=”Freespace(GB)”; Expression={“{0:N2}”
-f ($.Freespace/1GB)}},@{Name=”% Available)”; Expression={“{0:N1}”
-f (($
.Freespace/1GB) / ($_.Capacity/1GB)*100)}}

And, since we are using WMI, you can do this remotely by adding –ComputerName to the command

Get-WmiObject
Win32Volume
_-ComputerName
MyComputerName | Select Name, @{Name=”Size(GB)”; Expression={“{0:N2}”
-f ($.Capacity/1GB)}},@{Name=”Freespace(GB)”; Expression={“{0:N2}”
-f ($
.Freespace/1GB)}},@{Name=”% Available)”; Expression={“{0:N1}”
-f (($.Freespace/1GB) / ($.Capacity/1GB)*100)}}

Easy Right!

J

Be social and share this post!
Share via OneNote