I need to determine if the PsCustomObject array PsCustomObject an element with a Title property matching the value. I need a boolean value to use with Pester statements:
$Items -<function> $Name | Should Be $True
Assuming that:
$Items=@ () $Items+=[PsCustomObject]@{Title='foo';Url='http://f.io'} $Items+=[PsCustomObject]@{Title='bar';Url='http://b.io'}
Contains does not work:
PS> $Items -contains 'foo' False
Match returns the corresponding instance, but not logical:
PS> $Items -match 'foo' Title Url ----- --- foo http:
I suppose I could:
($Items -Match $Name).Count | Should Be 1
Is there a better option?
craig source share