Finding Positional Parameters

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!


Posted Feb 17 2010, 08:00 AM by ps1
Concentrated Tech NSoftware Dell Compellent Sponsored by Idera and Concentrated Tech and NSoftware and Dell Compellent
Copyright 2011 PowerShell.com. All rights reserved.