syntax – How important is parameter order when calling powershell cmdlets?

syntax – How important is parameter order when calling powershell cmdlets?

If you are naming your parameters when invoking a cmdlet (e.g.Get-ChildItem -Path *.txt) then it doesnt matter what order you specify them in. Everything is exactly specified by name, so the order in which params were provided is not needed to resolve the arguments.

If you are NOT naming your parameters (e.g. Get-ChildItem *.txt) then it does matter. The cmdlet author can specify that certain parameters can/should be expected, without names, in a certain order. The Powershell engine will try its best to honor that, and in general it will try to pair un-named arguments to any parameters which have not yet been assigned.

Check out this page on parameter types for some more technical info.

syntax – How important is parameter order when calling powershell cmdlets?

Leave a Reply

Your email address will not be published.