Skip to content

Commit 8a1dd8e

Browse files
committed
Separate parameter sets for Set-AzureRmVM -Redeploy and -Generalized
Azure#1909
1 parent ccfbc1c commit 8a1dd8e

File tree

1 file changed

+53
-4
lines changed

1 file changed

+53
-4
lines changed

src/ResourceManager/Compute/Commands.Compute/VirtualMachine/Action/SetAzureVMCommand.cs

Lines changed: 53 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -19,10 +19,45 @@
1919

2020
namespace Microsoft.Azure.Commands.Compute
2121
{
22-
[Cmdlet(VerbsCommon.Set, ProfileNouns.VirtualMachine, DefaultParameterSetName = ResourceGroupNameParameterSet)]
22+
[Cmdlet(VerbsCommon.Set, ProfileNouns.VirtualMachine, DefaultParameterSetName = GeneralizeResourceGroupNameParameterSet)]
2323
[OutputType(typeof(PSComputeLongRunningOperation))]
24-
public class SetAzureVMCommand : VirtualMachineActionBaseCmdlet
24+
public class SetAzureVMCommand : VirtualMachineBaseCmdlet
2525
{
26+
protected const string GeneralizeResourceGroupNameParameterSet = "GeneralizeResourceGroupNameParameterSetName";
27+
protected const string RedeployResourceGroupNameParameterSet = "RedeployResourceGroupNameParameterSetName";
28+
protected const string GeneralizeIdParameterSet = "GeneralizeIdParameterSetName";
29+
protected const string RedeployIdParameterSet = "RedeployIdParameterSetName";
30+
31+
[Parameter(
32+
Mandatory = true,
33+
Position = 0,
34+
ParameterSetName = GeneralizeResourceGroupNameParameterSet,
35+
ValueFromPipelineByPropertyName = true,
36+
HelpMessage = "The resource group name.")]
37+
[Parameter(
38+
Mandatory = true,
39+
Position = 0,
40+
ValueFromPipelineByPropertyName = true,
41+
ParameterSetName = RedeployResourceGroupNameParameterSet,
42+
HelpMessage = "The resource group name.")]
43+
[ValidateNotNullOrEmpty]
44+
public string ResourceGroupName { get; set; }
45+
46+
[Parameter(
47+
Mandatory = true,
48+
Position = 0,
49+
ParameterSetName = GeneralizeIdParameterSet,
50+
ValueFromPipelineByPropertyName = true,
51+
HelpMessage = "The resource group name.")]
52+
[Parameter(
53+
Mandatory = true,
54+
Position = 0,
55+
ParameterSetName = RedeployIdParameterSet,
56+
ValueFromPipelineByPropertyName = true,
57+
HelpMessage = "The resource group name.")]
58+
[ValidateNotNullOrEmpty]
59+
public string Id { get; set; }
60+
2661
[Parameter(
2762
Mandatory = true,
2863
Position = 1,
@@ -32,17 +67,31 @@ public class SetAzureVMCommand : VirtualMachineActionBaseCmdlet
3267
public string Name { get; set; }
3368

3469
[Parameter(
35-
Mandatory = false,
70+
Mandatory = true,
71+
Position = 2,
72+
ValueFromPipelineByPropertyName = true,
73+
ParameterSetName = GeneralizeResourceGroupNameParameterSet,
74+
HelpMessage = "To generalize virtual machine.")]
75+
[Parameter(
76+
Mandatory = true,
3677
Position = 2,
3778
ValueFromPipelineByPropertyName = true,
79+
ParameterSetName = GeneralizeIdParameterSet,
3880
HelpMessage = "To generalize virtual machine.")]
3981
[ValidateNotNullOrEmpty]
4082
public SwitchParameter Generalized { get; set; }
4183

4284
[Parameter(
43-
Mandatory = false,
85+
Mandatory = true,
86+
Position = 2,
87+
ValueFromPipelineByPropertyName = true,
88+
ParameterSetName = RedeployResourceGroupNameParameterSet,
89+
HelpMessage = "To redeploy virtual machine.")]
90+
[Parameter(
91+
Mandatory = true,
4492
Position = 2,
4593
ValueFromPipelineByPropertyName = true,
94+
ParameterSetName = RedeployIdParameterSet,
4695
HelpMessage = "To redeploy virtual machine.")]
4796
[ValidateNotNullOrEmpty]
4897
public SwitchParameter Redeploy { get; set; }

0 commit comments

Comments
 (0)