Home Dashboard Directory Help
Search

Parameter position ON/OFF switch with $PSDefaultParameterValues by S.K. _


Status: 

Active


1
0
Sign in
to vote
Type: Suggestion
ID: 775553
Opened: 1/1/2013 11:29:58 PM
Access Restriction: Public
0
Workaround(s)
view

Description

*** [PRECONDITION] $PSDefaultParameterValues is exist for short typing ***

When I use $PSDefaultParameterValues against parameters that have position,
I want they to turn off their position.


In New-PSDrive, -PSProvider parameter has position 2, and -Root parameter has position 3.
Even if I substitute a default value for -PSProvider parameter,
I cannot set -Root parameter's value without -PSProvider parameter's value using positions.

>> $PSDefaultParameterValues['New-PSDrive:PSProvider'] = "FileSystem"

>> New-PSDrive K //server/share ### want to set folder path to -Root parameter ###

cmdlet New-PSDrive at command pipeline position 1
Supply values for the followingparameters:
Root:


For avoiding this, I need to use named parameter

>> New-PSDrive K -Root //server/share # using named parameter

>> New-PSDrive K FileSystem //server/share # without defalut parameter

Now, there is no meaning using $PSDefaultParameterValues for short typing, yey!! :-<



If there is position ON/OFF switch...

>>> $PSDefaultParameterValues['New-PSDrive:PSProvider'].position = $false

>> New-PSDrive K //server/share

Name     Used (GB)     Free (GB) Provider     Root                 CurrentLocation
----     ---------     --------- --------     ----                 ---------------
K                            5.30 FileSystem    //server/share


Yey, I get short typing.
Details
Sign in to post a comment.
Sign in to post a workaround.