Finding Cmdlet Parameter Positions

by Oct 29, 2009

You can find out which cmdlet parameters are positional by using this line:

get-help dir -parameter * |
Where-Object { $_.Position -as [Int] } |
Sort-Object Position

This will list all positional parameters for "dir" (replace dir with any cmdlet name or cmdlet alias). Where-Object checks whether the position property can be converted to an integer value. If so, it is a positional parameter. If not, it is a named parameter and excluded from the list.

Once you know the positional parameters for a cmdlet, you can simply submit the values for the cmdlet in the correct order. The next command will then create a new PSDrive named "test:" that lists the system32 subfolder:

New-PSDrive test FileSystem $env:windir\system32
Dir test:

Twitter This Tip! ReTweet this Tip!