Here's what the Output looks like:
TotalCapacity TotalUsedSpace Server ------------- -------------- ------ 571,7 Gb 228,3 Gb SRV-SAPCS001 161,7 Gb 17,9 Gb SRV-IIS001 109,7 Gb 15,4 Gb SRV-IIS002
Here's the script:
"srv-sapcs001.katalykt.lan", "srv-iis001.katalykt.lan", "srv-iis002.katalykt.lan" |
ForEach-Object {Get-WmiObject Win32_LogicalDisk -ComputerName $_ -Filter "Drivetype=3"} |
Select-Object SystemName, Size, @{Label = "Used Space";Expression = {$_.Size - $_.FreeSpace}} |
Group-Object SystemName |
ForEach-Object {
New-Object PSObject -Property @{
Server = $_.Group.SystemName[0]
TotalUsedSpace = ("{0:N1} Gb" -f (($_.Group."Used Space" | Measure-Object -Sum).Sum / 1Gb))
TotalCapacity = ("{0:N1} Gb" -f (($_.Group.Size | Measure-Object -Sum).Sum / 1Gb))
}
}