Skip to content

July 12, 2011

View Remote Drive Space in Powershell

by Scott Newman

Quick script to view the drive information for remote systems in powershell.  Just pass in the server name as a param.

param
(
	[string]$ComputerName = ""
)

$drives = gwmi win32_logicaldisk -filter "drivetype=3" -ComputerName ($ComputerName)
$server = @{n = "Server"; e = {$_.__SERVER}}
$free = @{n = "FreeSpace(GB)"; e = {"{0:N2}" -f ($_.FreeSpace/1GB)}}
$Size = @{n = "Size(GB)"; e = {"{0:N2}" -f ($_.Size/1GB)}}
$Label = @{n = "Volume Name"; e = {$_.VolumeName}}
$Percentage = @{n = "PercentageFree"; e = {"{0:N2}" -f `
	([Int64]$_.FreeSpace / [Int64]($_.Size) * 100)}}
$drives | select $server, $Label, DeviceID, $free, $Size, $Percentage | ft -auto

image

Read more from Powershell

Leave a Reply

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

WordPress.com Logo

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

Google+ photo

You are commenting using your Google+ 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 )

Connecting to %s

Note: HTML is allowed. Your email address will never be published.

Subscribe to comments

%d bloggers like this: