
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
- Active Directory
- Cluster
- Database
- Exchange
- Files and folders
- Hardware
- Network
- Operating System
- PKI
- SCCM
- Service and process
- Tips
- VMWare
Get the free space on remote computer disks