The specific problem I am trying to solve is with a list of VMs and their hosts that I derived using powercli, but I think this is a question that might be asked more generally for any list of powershell objects.
I have a list of objects and their properties. I would like to compare each object in that list to all other objects in that list, and see which of those VMs have that property in common.
$vms = Get-VM | Where-Object {$_.Name -like '*vma*'} | Select Name, VMHost
Is there a relatively simple way to then iterate through the list and compare each objects to every other object in that list and see which objects have an identical "VMHost" property? Most of the questions I have found are about comparing two arrays of objects, but I'm not sure that helps here.
The end goal is to generate a report which highlights VMs whose names match a specific string and share a host, so that they can be checked manually and moved to other hosts if needed.
| Group-Object -property VMHost?