Finding Positional Parameters

by Feb 17, 2010

Positional parameters can be great time savers as many cmdlets assign a parameter position to its most widely used parameters. This way you do not need to specify the parameter name. You should instead just make sure you submit your arguments in the expected order. This is why the following command works:

Dir $env:windir *.log -recurse

Now, how do you know the positional parameters a cmdlet supports? Try this:

get-help Dir -parameter * |
where-object { ($_.position -as [Int32]) -ne $null }

Simply replace "Dir" with the cmdlet name (or alias) that you would like to know more about.

Twitter This Tip! ReTweet this Tip!