View Remote Drive Space in Powershell

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

Advertisements

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 )

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: