Could you tell my why this works:
Get-WmiObject Win32_LogicalDisk -ComputerName xxx, yyy, zzz -Filter "DeviceID='C:'" | Select-Object pscomputername, @{Name="Size GB";Expression={ "{0:N2}" -f ($_.Size / 1GB)}}, @{Name="Free GB";Expression={ "{0:N2}" -f ($_.FreeSpace / 1GB) }}
And this is not:
$Machines = "xxx, yyyy, zzz"
Get-WmiObject Win32_LogicalDisk -ComputerName $Machines -Filter "DeviceID='C:'" | Select-Object pscomputername, @{Name="Size GB";Expression={ "{0:N2}" -f ($_.Size / 1GB)}}, @{Name="Free GB";Expression={ "{0:N2}" -f ($_.FreeSpace / 1GB) }}
?
I'm really confused. I tried to change $Machines to:
xxx, yyy, zzz
@(xxx, yyy, zzz)
The error I'm getting is:
Get-WmiObject : The RPC server is unavailable. (Exception from HRESULT: 0x800706BA) At C:\AppSupport\ps\freespace\freespace.ps1:10 char:1 + Get-WmiObject Win32_LogicalDisk -ComputerName $Machines -Filter "DeviceID='C:'" ... + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + CategoryInfo : InvalidOperation: (:) [Get-WmiObject], COMException