Free Space on Remote Disks

To view the list of logical disks on a remote PC, you can use the Get-WMIObject commandlet passing the Win32_LogicalDisk parameter.

I needed to get information on specific disks on a specific server, so I knew which computer name and DeviceID to look for:

$remoteserver = ""

$filter = "DeviceID='C:' or DeviceID='E:'"

get-wmiobject -computer $remoteserver -class Win32_LogicalDisk -filter $filter |

    format-table `

        @{Expression={ $_.DeviceID }; Label="Drive"; Width=8},

        @{Expression={ [Math]::Truncate($_.Size / 1gb) }; Label ="Size GB"; Width=8},

        @{Expression={ [Math]::Truncate($_.FreeSpace / 1gb) }; Label="Free GB"; Width=8},

        @{Expression={ [Math]::Truncate(100 * $_.FreeSpace / $_.Size) }; Label="% Free"; Width=8}

These few lines of code give me the drive letter, drive size and free space in gigabytes, and percentage free space.

Of course, you can find quite many different solutions, like this one, a script that you can invoke with parameters.

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: