Get the free space on remote computer disks
Get the free space on remote computer disks

With this simple script, you will be able to get the free space available on the C: drive on a list of remote computers. I’m using WMI to request the remote computers.
You can use two different ways for the remote computer list :

  • static text file with one hostname per line
  • dynamic way using the get-adcomputer cmdlet

Just comment/uncomment the line of your choice in the script below ($list variable)

The returned value is in GB.

#$list = get-adcomputer -filter * -Properties operatingsystem -SearchBase "OU=MyOU,DC=domain,DC=local" | %{ $_.DNSHostName }
$list = gc C:\temp\hosts.txt

$list | % {
	$hostname = $_
	$hostname
	$value = (Get-WmiObject -ComputerName $hostname -Query "select freespace,caption from Win32_Volume where caption='C:\\'").freespace
	$value / 1Gb
}

<>

My Powershell script categories

Get the free space on remote computer disks

Leave a Reply

Your email address will not be published.