View Single Post
Old 05-14-2007   #2 (permalink)
Roman Kuzmin


 
 

Re: Newbie: filter rows with variable

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


My System SpecsSystem Spec