SCENARIO
- I m writing a cmdlet for Powershell 2.0 using Visual Studio 2008 and .NET 3.5
- the cmdlet requires 3 arguments.
my intended grammar of the cmdlet is something like this:
cmdletname [foo|bar] p1, p2
- That reads as the user must give a value for "-foo" or "-bar" but can t give both together.
EXAMPLE OF VALID INPUT
cmdletname -foo xxx -p1 hello -p2 world
cmdletname -bar yyy -p1 hello -p2 world
EXAMPLE OF INVALID INPUT
cmdletname -foo xxx -bar yyy -p1 hello -p2 world
MY QUESTION
- My question is on how to do this in powershell so that it does all the checking for me - or if that is possible at all.
- I know I can use just have two optional parameters for foo and bar and simply do the error checking manually. That s how I have it implemented currently.
- Alternatively, I am interested in suggestions for different approaches.