Script Parameter Alias
i modified 1 of scripts adding new switch parameter, gave parameter alias of "db", when run script .\myscript.ps1 -db following error
parameter alias cannot specified because alias name 'db' defined multiple times command.
@ line:1 char:1
+ .\myscript.ps1 -db
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ categoryinfo : metadataerror: (:) [], metadataexception
+ fullyqualifiederrorid : aliasparameternamealreadyexistsforcommand
in script not have other aliases called "db", there 1 called "d", , if get-alias, there alias of "dbp". why can not use alias of "db"?
if find post has answered question, please mark answer. if find post helpful in anyway, please click vote helpful.
hi clayman,
i figured out (i think):
"db" reserved parameter alias, used -debug parameter. without cmdletbinding, powershell not abide use.
btw, there no point in assigning default values switches - $false if not set. there no meaning in validatepattern $wonumber (it's numeric type already. use validaterange limit specific number range).
cheers,
fred
there's no place 127.0.0.1
Windows Server > Windows PowerShell
Comments
Post a Comment