@@ -36,6 +36,8 @@ public class SetAzureVMOperatingSystemCommand : Microsoft.Azure.Commands.Resourc
3636 {
3737 protected const string WindowsParamSet = "Windows" ;
3838 protected const string WinRmHttpsParamSet = "WindowsWinRmHttps" ;
39+ protected const string WindowsDisableVMAgentParamSet = "WindowsDisableVMAgent" ;
40+ protected const string WindowsDisableVMAgentWinRmHttpsParamSet = "WindowsDisableVMAgentWinRmHttps" ;
3941 protected const string LinuxParamSet = "Linux" ;
4042
4143 [ Alias ( "VMProfile" ) ]
@@ -60,6 +62,18 @@ public class SetAzureVMOperatingSystemCommand : Microsoft.Azure.Commands.Resourc
6062 Position = 1 ,
6163 ValueFromPipelineByPropertyName = true ,
6264 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" ) ]
6377 [ ValidateNotNullOrEmpty ]
6478 public SwitchParameter Windows { get ; set ; }
6579
@@ -108,6 +122,15 @@ public class SetAzureVMOperatingSystemCommand : Microsoft.Azure.Commands.Resourc
108122 [ ValidateNotNullOrEmpty ]
109123 public SwitchParameter ProvisionVMAgent { get ; set ; }
110124
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+
111134 [ Parameter (
112135 ParameterSetName = WindowsParamSet ,
113136 Position = 6 ,
@@ -118,6 +141,16 @@ public class SetAzureVMOperatingSystemCommand : Microsoft.Azure.Commands.Resourc
118141 Position = 6 ,
119142 ValueFromPipelineByPropertyName = true ,
120143 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" ) ]
121154 [ ValidateNotNullOrEmpty ]
122155 public SwitchParameter EnableAutoUpdate { get ; set ; }
123156
@@ -131,6 +164,16 @@ public class SetAzureVMOperatingSystemCommand : Microsoft.Azure.Commands.Resourc
131164 Position = 7 ,
132165 ValueFromPipelineByPropertyName = true ,
133166 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" ) ]
134177 [ ValidateNotNullOrEmpty ]
135178 public string TimeZone { get ; set ; }
136179
@@ -144,6 +187,16 @@ public class SetAzureVMOperatingSystemCommand : Microsoft.Azure.Commands.Resourc
144187 Position = 8 ,
145188 ValueFromPipelineByPropertyName = true ,
146189 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" ) ]
147200 [ ValidateNotNullOrEmpty ]
148201 public SwitchParameter WinRMHttp { get ; set ; }
149202
@@ -153,6 +206,12 @@ public class SetAzureVMOperatingSystemCommand : Microsoft.Azure.Commands.Resourc
153206 Position = 9 ,
154207 ValueFromPipelineByPropertyName = true ,
155208 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" ) ]
156215 [ ValidateNotNullOrEmpty ]
157216 public SwitchParameter WinRMHttps { get ; set ; }
158217
@@ -162,6 +221,12 @@ public class SetAzureVMOperatingSystemCommand : Microsoft.Azure.Commands.Resourc
162221 Position = 10 ,
163222 ValueFromPipelineByPropertyName = true ,
164223 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" ) ]
165230 [ ValidateNotNullOrEmpty ]
166231 public Uri WinRMCertificateUrl { get ; set ; }
167232
@@ -235,7 +300,17 @@ public override void ExecuteCmdlet()
235300 }
236301
237302 // OS Profile
238- this . VM . OSProfile . WindowsConfiguration . ProvisionVMAgent = this . ProvisionVMAgent . IsPresent ;
303+ this . VM . OSProfile . WindowsConfiguration . ProvisionVMAgent = this . VM . OSProfile . WindowsConfiguration . ProvisionVMAgent ;
304+
305+ if ( this . ProvisionVMAgent . IsPresent )
306+ {
307+ this . VM . OSProfile . WindowsConfiguration . ProvisionVMAgent = true ;
308+ }
309+
310+ if ( this . DisableVMAgent . IsPresent )
311+ {
312+ this . VM . OSProfile . WindowsConfiguration . ProvisionVMAgent = false ;
313+ }
239314
240315 this . VM . OSProfile . WindowsConfiguration . EnableAutomaticUpdates = this . EnableAutoUpdate . IsPresent ;
241316
0 commit comments