|
Re: Newbie: filter rows with variable This is known issue... I cannot recall exactly what the exact issue is, but
I know I have it baked in my brain never to use $args directly.
"Roman Kuzmin" <z@z.z> wrote in message
news:edDzeZhlHHA.4032@TK2MSFTNGP02.phx.gbl...
> 1) I guess in this context $args is arguments of a script block {$_ -like
> "*$args*"} passed into Where-Object cmdlet (but, strange, all lines should
> be returned in your example, IMO...). Try this way:
>
> function foo
> {
> $myArgs = $args
> gc <.> | where {$_ -like "*$myArgs*"} | sort
> }
>
> foo '<pattern>'
>
> 2) Is this OK?:
>
> .\list.ps1 '@work'
> or
>
> .\list.ps1 "@work"
>
> --
> Thanks,
> Roman Kuzmin
>
> |