Ok, we're going to add an additional member to your custom objects so that they remember who they are once they're added to the array. Then we'll filter using -match
and we'll get what you want.
$obj1 = New-Object PSObject -Property @{
"Name" = "Obj1"
"Prop1" = $true
"Prop2" = $true
"Prop3" = $true
}
$obj2 = New-Object PSObject -Property @{
"Name" = "Obj2"
"Prop1" = $true
"Prop2" = $false
"Prop3" = $true
}
$objarray = @($obj1, $obj2)
$fails = $objarray | Where-Object { $_ -match $false }
I suppose if you really, really want it to return $obj2
you could escape a $
into the Name value like "Name" =
"`$obj2"