We will be applying production windows updates to all of our production servers shortly and I wanted to manually verify that we had at least 2GB free on all of our C: drives in preparation for the update. We have automated monitoring systems but I wanted to grab the information directly to ensure it was accurate. I exported a list of all of our servers into a text file and ran the following PowerShell to produce a list of all of the C: drives free space. I then copied and pasted this into Excel. Quick and dirty but it works great.
$computers = Import-Csv c:\temp\hostlist.txt
$computers | % {
$Results = Get-WmiObject Win32_LogicalDisk -ComputerName $_.ServerList -Filter “DeviceID=’C:'” -ErrorAction SilentlyContinue |
Select-Object Size,@{Name=”FreeSize”;Expression={“{0:N1}” -f($_.freespace/1gb) } }
if ($? -eq $True) { Write-Host $Computer.ServerList $Results.FreeSize }
}