Search This Blog and Web

Tuesday, October 21, 2014

[Script] Get Disk Space using PowerShell

I posted a simple script at Technet which returns the free space of a specific drive on any computer.

Take a look here :

Basic Code :

Write-Host "Getting Information for Drive : $DriveID for Computer : $CompName" 
# Get Info about the disk specified 
$Disk = Get-WMIObject Win32_LogicalDisk -ComputerName $CompName -Filter "DeviceID='$DriveID'"  
$FreeSpace = [System.Math]::Round((($Disk.FreeSpace) / 1GB)) 
Write-Host "Drive $DriveID has freespace : $FreeSpace GB"

The script can be improved using PS-Remoting for better performance.

Featured Post

Timeout problem in Backup-SQLDatabase cmdlet in SQLPS module

Power Shell is for managing all types of technologies be it SQL, EXchange, Lync, Office etc.( just name it ) These technologies usually cr...