powershell v2, use cmdlet with parameters known only at truntime -
i need utilize cmdlet know parameter utilize @ runtime.
for ex, may need phone call
get-childitem -filter <string>
or
get-childitem -exclude <string>
or
get-childitem -recurse
etc.
but know @ runtime of -filter or -exclude or -recurse or combination of them needed.
[ get-childitem illustration illustrate need not real thing ]
is possible except using huge if-then-else construction ? possible utilize cmdlet selecting parameters @ runtime ?
tia, peyre.
using illustration can this:
function test ($value , [switch]$parama, [switch]$paramb) { if ($parama) { $cmd = "-filter $value" } if($paramb) { $cmd = "-exclude $value" } iex "dir $cmd" }
to test seek this:
test -value *.ps1 -parama
or
test -value *.ps1 -paramb
powershell-v2.0
No comments:
Post a Comment