Archive for February, 2014

I was working on a project and needed to remotely check a servers available disk space so I started trying to come up with a simple reusable function to check the disk space.  The following is what I came up with. 

Function GetDiskSpace

GetDiskSpace displays the Total Size and Total Free Space of a Remote Computer Drive
See synopsis
To run – enter GetDiskSpace
$computer = Read-host "Please enter the computer name"
$drive = Read-host "Please enter the drive letter including the colon (c:)"
$disk = Get-WmiObject Win32_LogicalDisk -ComputerName $computer -Filter "DeviceID=’$drive’" | Select-Object Size,FreeSpace
"Remote computer: $computer drive letter $drive has {0:#.0} GB free of {1:#.0} GB Total" -f ($disk.FreeSpace/1GB),($disk.Size/1GB) | write-output

Set-alias GDS GetDiskSpace


Read Full Post »