In PowerShell I have tried:
alias | select-string Alias
This fails even though Alias
is clearly in the output. I know this is beca
For a more flexible and lazy solution, you could match all properties of the objects. Most of the time, this should get you the behavior you want, and you can always be more specific when it doesn't. Here's a grep function that works based on this principle:
Function Select-ObjectPropertyValues {
param(
[Parameter(Mandatory=$true,Position=0)]
[String]
$Pattern,
[Parameter(ValueFromPipeline)]
$input)
$input | Where-Object {($_.PSObject.Properties | Where-Object {$_.Value -match $Pattern} | Measure-Object).count -gt 0} | Write-Output
}