email

Tuesday, August 4, 2009

Find disk space of remote machine with powershell script

Subject says it all. This code helps you to findout the disk space of remote machine.

Code(save it into a file with ps1 extension):
$hostname=Read-host "Enter the computer name"
get-wmiobject -computer $hostname win32_logicaldisk -filter "drivetype=3" | ForEach-Object { Write-Host  Device name : $_.deviceid\; write-host Total space : ($_.size/1GB).tostring("0.00")GB; write-host Free Spce : ($_.freespace/1GB).tostring("0.00")GB }

Output
PS C:\temp> .\CheckSpace.ps1
Enter the computer name: MyRemotePC
Device name : C: \
Total space : 232.75 GB
Free Spce : 130.51 GB
PS C:\temp\>

No comments:

Post a Comment