@@ -36,6 +36,8 @@ public class SetAzureVMOperatingSystemCommand : Microsoft.Azure.Commands.Resourc
36
36
{
37
37
protected const string WindowsParamSet = "Windows" ;
38
38
protected const string WinRmHttpsParamSet = "WindowsWinRmHttps" ;
39
+ protected const string WindowsDisableVMAgentParamSet = "WindowsDisableVMAgent" ;
40
+ protected const string WindowsDisableVMAgentWinRmHttpsParamSet = "WindowsDisableVMAgentWinRmHttps" ;
39
41
protected const string LinuxParamSet = "Linux" ;
40
42
41
43
[ Alias ( "VMProfile" ) ]
@@ -60,6 +62,18 @@ public class SetAzureVMOperatingSystemCommand : Microsoft.Azure.Commands.Resourc
60
62
Position = 1 ,
61
63
ValueFromPipelineByPropertyName = true ,
62
64
HelpMessage = "Windows" ) ]
65
+ [ Parameter (
66
+ ParameterSetName = WindowsDisableVMAgentParamSet ,
67
+ Mandatory = true ,
68
+ Position = 1 ,
69
+ ValueFromPipelineByPropertyName = true ,
70
+ HelpMessage = "Windows" ) ]
71
+ [ Parameter (
72
+ ParameterSetName = WindowsDisableVMAgentWinRmHttpsParamSet ,
73
+ Mandatory = true ,
74
+ Position = 1 ,
75
+ ValueFromPipelineByPropertyName = true ,
76
+ HelpMessage = "Windows" ) ]
63
77
[ ValidateNotNullOrEmpty ]
64
78
public SwitchParameter Windows { get ; set ; }
65
79
@@ -108,6 +122,15 @@ public class SetAzureVMOperatingSystemCommand : Microsoft.Azure.Commands.Resourc
108
122
[ ValidateNotNullOrEmpty ]
109
123
public SwitchParameter ProvisionVMAgent { get ; set ; }
110
124
125
+ [ Parameter (
126
+ ParameterSetName = WindowsDisableVMAgentParamSet ,
127
+ HelpMessage = "Disable Provision VM Agent." ) ]
128
+ [ Parameter (
129
+ ParameterSetName = WindowsDisableVMAgentWinRmHttpsParamSet ,
130
+ HelpMessage = "Disable Provision VM Agent." ) ]
131
+ [ ValidateNotNullOrEmpty ]
132
+ public SwitchParameter DisableVMAgent { get ; set ; }
133
+
111
134
[ Parameter (
112
135
ParameterSetName = WindowsParamSet ,
113
136
Position = 6 ,
@@ -118,6 +141,16 @@ public class SetAzureVMOperatingSystemCommand : Microsoft.Azure.Commands.Resourc
118
141
Position = 6 ,
119
142
ValueFromPipelineByPropertyName = true ,
120
143
HelpMessage = "Enable Automatic Update" ) ]
144
+ [ Parameter (
145
+ ParameterSetName = WindowsDisableVMAgentParamSet ,
146
+ Position = 6 ,
147
+ ValueFromPipelineByPropertyName = true ,
148
+ HelpMessage = "Enable Automatic Update" ) ]
149
+ [ Parameter (
150
+ ParameterSetName = WindowsDisableVMAgentWinRmHttpsParamSet ,
151
+ Position = 6 ,
152
+ ValueFromPipelineByPropertyName = true ,
153
+ HelpMessage = "Enable Automatic Update" ) ]
121
154
[ ValidateNotNullOrEmpty ]
122
155
public SwitchParameter EnableAutoUpdate { get ; set ; }
123
156
@@ -131,6 +164,16 @@ public class SetAzureVMOperatingSystemCommand : Microsoft.Azure.Commands.Resourc
131
164
Position = 7 ,
132
165
ValueFromPipelineByPropertyName = true ,
133
166
HelpMessage = "Time Zone" ) ]
167
+ [ Parameter (
168
+ ParameterSetName = WindowsDisableVMAgentParamSet ,
169
+ Position = 7 ,
170
+ ValueFromPipelineByPropertyName = true ,
171
+ HelpMessage = "Time Zone" ) ]
172
+ [ Parameter (
173
+ ParameterSetName = WindowsDisableVMAgentWinRmHttpsParamSet ,
174
+ Position = 7 ,
175
+ ValueFromPipelineByPropertyName = true ,
176
+ HelpMessage = "Time Zone" ) ]
134
177
[ ValidateNotNullOrEmpty ]
135
178
public string TimeZone { get ; set ; }
136
179
@@ -144,6 +187,16 @@ public class SetAzureVMOperatingSystemCommand : Microsoft.Azure.Commands.Resourc
144
187
Position = 8 ,
145
188
ValueFromPipelineByPropertyName = true ,
146
189
HelpMessage = "Enable WinRM Http protocol" ) ]
190
+ [ Parameter (
191
+ ParameterSetName = WindowsDisableVMAgentParamSet ,
192
+ Position = 8 ,
193
+ ValueFromPipelineByPropertyName = true ,
194
+ HelpMessage = "Enable WinRM Http protocol" ) ]
195
+ [ Parameter (
196
+ ParameterSetName = WindowsDisableVMAgentWinRmHttpsParamSet ,
197
+ Position = 8 ,
198
+ ValueFromPipelineByPropertyName = true ,
199
+ HelpMessage = "Enable WinRM Http protocol" ) ]
147
200
[ ValidateNotNullOrEmpty ]
148
201
public SwitchParameter WinRMHttp { get ; set ; }
149
202
@@ -153,6 +206,12 @@ public class SetAzureVMOperatingSystemCommand : Microsoft.Azure.Commands.Resourc
153
206
Position = 9 ,
154
207
ValueFromPipelineByPropertyName = true ,
155
208
HelpMessage = "Enable WinRM Https protocol" ) ]
209
+ [ Parameter (
210
+ Mandatory = true ,
211
+ ParameterSetName = WindowsDisableVMAgentWinRmHttpsParamSet ,
212
+ Position = 9 ,
213
+ ValueFromPipelineByPropertyName = true ,
214
+ HelpMessage = "Enable WinRM Https protocol" ) ]
156
215
[ ValidateNotNullOrEmpty ]
157
216
public SwitchParameter WinRMHttps { get ; set ; }
158
217
@@ -162,6 +221,12 @@ public class SetAzureVMOperatingSystemCommand : Microsoft.Azure.Commands.Resourc
162
221
Position = 10 ,
163
222
ValueFromPipelineByPropertyName = true ,
164
223
HelpMessage = "Url for WinRM certificate" ) ]
224
+ [ Parameter (
225
+ Mandatory = true ,
226
+ ParameterSetName = WindowsDisableVMAgentWinRmHttpsParamSet ,
227
+ Position = 10 ,
228
+ ValueFromPipelineByPropertyName = true ,
229
+ HelpMessage = "Url for WinRM certificate" ) ]
165
230
[ ValidateNotNullOrEmpty ]
166
231
public Uri WinRMCertificateUrl { get ; set ; }
167
232
@@ -238,7 +303,17 @@ public override void ExecuteCmdlet()
238
303
}
239
304
240
305
// OS Profile
241
- this . VM . OSProfile . WindowsConfiguration . ProvisionVMAgent = this . ProvisionVMAgent . IsPresent ;
306
+ this . VM . OSProfile . WindowsConfiguration . ProvisionVMAgent = this . VM . OSProfile . WindowsConfiguration . ProvisionVMAgent ;
307
+
308
+ if ( this . ProvisionVMAgent . IsPresent )
309
+ {
310
+ this . VM . OSProfile . WindowsConfiguration . ProvisionVMAgent = true ;
311
+ }
312
+
313
+ if ( this . DisableVMAgent . IsPresent )
314
+ {
315
+ this . VM . OSProfile . WindowsConfiguration . ProvisionVMAgent = false ;
316
+ }
242
317
243
318
this . VM . OSProfile . WindowsConfiguration . EnableAutomaticUpdates = this . EnableAutoUpdate . IsPresent ;
244
319
0 commit comments