Linked Questions

Popular Questions

Mandatory flag with a message command line args

Asked by At

I cannot seem to figure out if this is possible or not. I want to validate the command line args if they are missing args print a pretty message.

For example

[Parameter(Mandatory=$True,HelpMessage="User Name must be specified.")]

Now if I run my script from the command line, it still prints out this ugly red message at the bottom:

Missing an argument for parameter 'userName'. Specify a parameter of type 'System.String' and try again.

How do I get it to print HelpMessage? Or better yet, call my own method with the missing param.

Related Questions