Objects with no '.Count' Property - use of @() (array subexpression operator) vs. [Array] cast
I am trying to perform some simple if statements, but all of the newer cmdlets that are based upon [Microsoft.Management.Infrastructure.CimInstance] don't seem to expose a .count method? $Disks = Get-Disk $Disks.Count Doesn't return anything. I found that I can cast this as an [array], which makes it returns a .NET .count method as expected. [Array]$Disks = Get-Disk $Disks.Count This works without directly casting it as an array for previous cmdlets: (Get-Services).Count What is the recommended way to get around this? An example that doesn't work: $PageDisk = Get-Disk | Where {($_.IsBoot -eq