So here's the fun times: I have an array with virtual server values in columns, etc. There's a ForEach loop that each server goes through, and I'm trying to weed out servers with a 0 count for Disks. Here's my syntax:
$VMInfo.Disks = Get-HardDisk -VM $VM | Measure-Object | Select-Object Count
In the exported CSV file, if there's not a hard disk the column has @{Count=0} as the value. So I figured this if statement would be a good way to weed out those servers from the report (this if statement is part of the ForEach overall command):
if ($VMInfo.Disks -ne "@{Count=0}") {
$Report += $VMInfo
}
However, when I include the if statement, I still get servers without a hard drive included in the exported CSV file. Any ideas? Do I need to change the $VMInfo.Disks -ne "@{Count=0}" command to something else? Any help would be greatly appreciated!
edit: Tried to use -gt 0 instead of -ne "@{Count=0}" but got the following error:
Cannot compare "@{Count=2}" to "0" because the objects are not the same type or the object "@{Count=2}" does not implement "IComparable".
edit: Tried to use @{Count=0} instead of "@{Count=0}" but it didn't make a difference - CSV still had columns with @{Count=0} in them.