Search for a unknown property in an object based on its value
$obj = [pscustomobject]@{'Haystack1'='test';'Haystack2'='needle'}$noteProperties = $obj|get-member -MemberType NoteProperty | select -ExpandProperty name$noteProperties | Where {$obj."$_" -match 'needle'}
and you can one-liner it with
$obj|gm -M NoteProperty|?{$obj."$($_.Name)"-match'needle'}
One possibility:
$obj = [pscustomobject]@{'Haystack1'='test';'Haystack2'='needle'}@($obj | Format-List *| Out-String).split("`n") -like '*needle*'Haystack2 : needle
$obj = [PSCustomObject]@{"Haystack1" = "test"; "Haystack2" = "needle"}$obj.PSObject.Properties | ? { $_.Value -eq "needle" }