In PowerShell 1.0, if I have a cmdlet parameter of an enum type, what is the recommended method for testing whether the user specified that parameter on the cmdlet command line? For example:
MyEnum : int { No = 0, Yes = 1, MaybeSo = 2 }
class DoSomethingCommand : PSCmdlet
...
private MyEnum isEnabled;
[Parameter(Mandatory = false)]
public MyEnum IsEnabled
{
get { return isEnabled; }
set { isEnabled = value; }
}
protected override void ProcessRecord()
{
// How do I know if the user passed -IsEnabled <value> to the cmdlet?
}
Is there any way to do this without having to seed isEnabled with a dummy value? By default it will equal 0, and I don't want to have to seed every parameter or add a dummy value to my enum. I've potentially got many cmdlets with 100's of parameters, there's got to be a better way. This is related to this question but I was looking for a cleaner way of doing this. Thanks.