$computers
is a array of server names.
If I do:
Get-WMIObject -ComputerName $computers Win32_LogicalDisk | Where-Object {$_.DriveType -eq 3} | Select-Object SystemName, name, Freespace, size
A list of the drive name, size etc is displayed on screen a expected.
SystemName name Freespace size
---------- ---- --------- ----
APP01 C: 25942634496 235667451904
APP01 E: 97153241088 376746012672
APP02 C: 39813332992 117555851264
App02 D: 18904997888 87909462016
PC-03 C: 21936656384 112187142144
PC-03 D: 155361820672 183472484352
APP04 C: 5994582016 117555851264
APP04 D: 50258378752 53550772224
If I do:
$DiskData = Get-WMIObject -ComputerName $computers Win32_LogicalDisk | Where-Object {$_.DriveType -eq 3} | Select-Object SystemName, name, Freespace, size
The variable $Diskdata
does not contain the results array as I woud expect. If I output the array it appears to contain nothing at all.
PS C:\Windows\system32> $DiskData
PS C:\Windows\system32>
However if i compare it to $NULL it is not null
PS C:\Windows\system32> $null -eq $DiskData
False
PS C:\Windows\system32> $DiskData.GetType()
IsPublic IsSerial Name BaseType
-------- -------- ---- --------
True True Object[] System.Array
Can anyone please tell me what is going on?
edit:
PS C:\Windows\system32> [System.Management.Automation.PSSerializer]::Serialize($DiskData)
<Objs Version="1.1.0.1" xmlns="http://schemas.microsoft.com/powershell/2004/04">
<Obj RefId="0">
<TN RefId="0">
<T>System.Object[]</T>
<T>System.Array</T>
<T>System.Object</T>
</TN>
<LST />
</Obj>
</Objs>