Getting Disk Usage Information

Nice bit of code and uses WMI!


Source: https://jtruher.spaces.live.com/Blog/cns!7143DA6E51A2628D!138.entry

Some of you might know that I've spent a lot of time on UNIX systems. One of the scripts that I used a bunch was /etc/dfspace. If you don't know what dfspace is, it's a simple wrapper for df that provides disk usage info in a more human readable format than the output of df. Since I really miss having that on Windows, I built it in powershell using the Get-WMIObject cmdlet. Here's how it looks when you run it:

PS> dfspace
name Size (MB) free (MB) percent
---- --------- --------- -------
C: 152,499.84 76,827.33 50.38