≡ Menu

Find disk space of remote machine with powershell script

I  wrote a enhanced function to get the disk space. You can find it at https://techibee.com/powershell/check-disk-space-of-remote-machine-using-powershell/430

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 }


PS C:temp> .CheckSpace.ps1
Enter the computer name: MyRemotePCDevice name : C: Total space : 232.75 GBFree Spce : 130.51 GBPS C:temp>

Comments on this entry are closed.

  • Fat Boy Tim September 21, 2011, 3:41 pm


    $servername = “XXX”
    Invoke-Command -ComputerName $servername -ScriptBlock { Get-PSDrive -PSProvider “FileSystem” }