Ed The Dev .com

Edward Delaporte's Technical Journal

PowerShell script to list the free space on your drives

no comment

Here is the command:

Get-WMIObject Win32_LogicalDisk | ForEach-Object {[math]::truncate($_.freespace / 1GB)}

But you could shorten it with some abbreviations:

gwmi Win32_LogicalDisk | % {[math]::truncate($_.freespace / 1GB)}

And if you want precision rather than a clean answer:

gwmi Win32_LogicalDisk | % {$_.freespace / 1GB}

The commands above will list the free space on each of your computers logical disks, so expect to see a list. Naturally, CD and DVD drives will be listed as having 0 free space.

Leave a Reply

You must be logged in to post a comment.