PowerShell mandatory parameter depends on another parameter
I have a PowerShell function which changes the registry key values. Code: param( [Parameter()] [switch]$CreateNewChild, [Parameter(Mandatory=$true)] [string]$PropertyType ) It has a parameter, "CreateNewChild", and if that flag is set, the function will create the key property, even if it wasn't found. The parameter "PropertyType" must be mandatory, but only if "CreateNewChild" flag has been set. The question is, how do I make a parameter mandatory, but only if another parameter has been specified? OK, I've been playing around with it. And this does work: param( [Parameter(ParameterSetName=