我要定义三个参数集
- cmdletName - param1 (ParameterSet1)
- cmdletName - param1 -param2 (ParameterSet2)
- cmdletName(这没有任何参数)(ParameterSet3)
我怎样才能做到这一点?
这就是我当前的代码的样子。
[Parameter(ParameterSetName = ParameterSet1, Mandatory = true, ValueFromPipelineByPropertyName = true, HelpMessage = "The ResourceGroupName")]
[Parameter(ParameterSetName = ParameterSet2, Mandatory = true, ValueFromPipelineByPropertyName = true, HelpMessage = "The ResourceGroupName")]
[Parameter(ParameterSetName = ParameterSet3, Mandatory = false, ValueFromPipelineByPropertyName = true, HelpMessage = "The ResourceGroupName")]
public String ResourceGroupName { get; set; }
[Parameter(ParameterSetName = ParameterSet2, Mandatory = true, ValueFromPipelineByPropertyName = true, HelpMessage = "The name of metric alert rule")]
[Parameter(ParameterSetName = ParameterSet3, Mandatory = false, ValueFromPipelineByPropertyName = true, HelpMessage = "The ResourceGroupName")]
public String Name { get; set; }