diff --git a/src/ResourceManager/Compute/ChangeLog.md b/src/ResourceManager/Compute/ChangeLog.md index 0e3f8734da3e..33a535c47822 100644 --- a/src/ResourceManager/Compute/ChangeLog.md +++ b/src/ResourceManager/Compute/ChangeLog.md @@ -18,6 +18,7 @@ - Additional information about change #1 --> ## Current Release +* Add DisableVMAgent switch parameter to `Set-AzureRmVMOperatingSystem` cmdlet * `New-AzureRmVm` and `New-AzureRmVmss` (simple parameter set) support a `Win10` image. * `Repair-AzureRmVmssServiceFabricUpdateDomain` cmdlet is added. * Set minimum dependency of module to PowerShell 5.0 diff --git a/src/ResourceManager/Compute/Commands.Compute.Test/ScenarioTests/VirtualMachineProfileTests.ps1 b/src/ResourceManager/Compute/Commands.Compute.Test/ScenarioTests/VirtualMachineProfileTests.ps1 index ad571fffcdcc..e48fe11d8237 100644 --- a/src/ResourceManager/Compute/Commands.Compute.Test/ScenarioTests/VirtualMachineProfileTests.ps1 +++ b/src/ResourceManager/Compute/Commands.Compute.Test/ScenarioTests/VirtualMachineProfileTests.ps1 @@ -399,4 +399,13 @@ function Test-VirtualMachineProfileWithoutAUC # Verify Additional Unattend Content Assert-Null $p.OSProfile.WindowsConfiguration.AdditionalUnattendContent "NULL"; Assert-False {$p.OSProfile.WindowsConfiguration.AdditionalUnattendContent.IsInitialized}; + + $p.OSProfile = $null; + $p = Set-AzureRmVMOperatingSystem -VM $p -Windows -ComputerName $computerName -Credential $cred; + Assert-Null $p.OSProfile.WindowsConfiguration.ProvisionVMAgent; + + $p.OSProfile = $null; + $p = Set-AzureRmVMOperatingSystem -VM $p -Windows -ComputerName $computerName -Credential $cred -DisableVMAgent; + Assert-False {$p.OSProfile.WindowsConfiguration.ProvisionVMAgent}; + } diff --git a/src/ResourceManager/Compute/Commands.Compute/VirtualMachine/Config/SetAzureVMOperatingSystemCommand.cs b/src/ResourceManager/Compute/Commands.Compute/VirtualMachine/Config/SetAzureVMOperatingSystemCommand.cs index fba26dafbfd3..74ca772c93be 100644 --- a/src/ResourceManager/Compute/Commands.Compute/VirtualMachine/Config/SetAzureVMOperatingSystemCommand.cs +++ b/src/ResourceManager/Compute/Commands.Compute/VirtualMachine/Config/SetAzureVMOperatingSystemCommand.cs @@ -36,6 +36,8 @@ public class SetAzureVMOperatingSystemCommand : Microsoft.Azure.Commands.Resourc { protected const string WindowsParamSet = "Windows"; protected const string WinRmHttpsParamSet = "WindowsWinRmHttps"; + protected const string WindowsDisableVMAgentParamSet = "WindowsDisableVMAgent"; + protected const string WindowsDisableVMAgentWinRmHttpsParamSet = "WindowsDisableVMAgentWinRmHttps"; protected const string LinuxParamSet = "Linux"; [Alias("VMProfile")] @@ -60,6 +62,18 @@ public class SetAzureVMOperatingSystemCommand : Microsoft.Azure.Commands.Resourc Position = 1, ValueFromPipelineByPropertyName = true, HelpMessage = "Windows")] + [Parameter( + ParameterSetName = WindowsDisableVMAgentParamSet, + Mandatory = true, + Position = 1, + ValueFromPipelineByPropertyName = true, + HelpMessage = "Windows")] + [Parameter( + ParameterSetName = WindowsDisableVMAgentWinRmHttpsParamSet, + Mandatory = true, + Position = 1, + ValueFromPipelineByPropertyName = true, + HelpMessage = "Windows")] [ValidateNotNullOrEmpty] public SwitchParameter Windows { get; set; } @@ -108,6 +122,15 @@ public class SetAzureVMOperatingSystemCommand : Microsoft.Azure.Commands.Resourc [ValidateNotNullOrEmpty] public SwitchParameter ProvisionVMAgent { get; set; } + [Parameter( + ParameterSetName = WindowsDisableVMAgentParamSet, + HelpMessage = "Disable Provision VM Agent.")] + [Parameter( + ParameterSetName = WindowsDisableVMAgentWinRmHttpsParamSet, + HelpMessage = "Disable Provision VM Agent.")] + [ValidateNotNullOrEmpty] + public SwitchParameter DisableVMAgent { get; set; } + [Parameter( ParameterSetName = WindowsParamSet, Position = 6, @@ -118,6 +141,16 @@ public class SetAzureVMOperatingSystemCommand : Microsoft.Azure.Commands.Resourc Position = 6, ValueFromPipelineByPropertyName = true, HelpMessage = "Enable Automatic Update")] + [Parameter( + ParameterSetName = WindowsDisableVMAgentParamSet, + Position = 6, + ValueFromPipelineByPropertyName = true, + HelpMessage = "Enable Automatic Update")] + [Parameter( + ParameterSetName = WindowsDisableVMAgentWinRmHttpsParamSet, + Position = 6, + ValueFromPipelineByPropertyName = true, + HelpMessage = "Enable Automatic Update")] [ValidateNotNullOrEmpty] public SwitchParameter EnableAutoUpdate { get; set; } @@ -131,6 +164,16 @@ public class SetAzureVMOperatingSystemCommand : Microsoft.Azure.Commands.Resourc Position = 7, ValueFromPipelineByPropertyName = true, HelpMessage = "Time Zone")] + [Parameter( + ParameterSetName = WindowsDisableVMAgentParamSet, + Position = 7, + ValueFromPipelineByPropertyName = true, + HelpMessage = "Time Zone")] + [Parameter( + ParameterSetName = WindowsDisableVMAgentWinRmHttpsParamSet, + Position = 7, + ValueFromPipelineByPropertyName = true, + HelpMessage = "Time Zone")] [ValidateNotNullOrEmpty] public string TimeZone { get; set; } @@ -144,6 +187,16 @@ public class SetAzureVMOperatingSystemCommand : Microsoft.Azure.Commands.Resourc Position = 8, ValueFromPipelineByPropertyName = true, HelpMessage = "Enable WinRM Http protocol")] + [Parameter( + ParameterSetName = WindowsDisableVMAgentParamSet, + Position = 8, + ValueFromPipelineByPropertyName = true, + HelpMessage = "Enable WinRM Http protocol")] + [Parameter( + ParameterSetName = WindowsDisableVMAgentWinRmHttpsParamSet, + Position = 8, + ValueFromPipelineByPropertyName = true, + HelpMessage = "Enable WinRM Http protocol")] [ValidateNotNullOrEmpty] public SwitchParameter WinRMHttp { get; set; } @@ -153,6 +206,12 @@ public class SetAzureVMOperatingSystemCommand : Microsoft.Azure.Commands.Resourc Position = 9, ValueFromPipelineByPropertyName = true, HelpMessage = "Enable WinRM Https protocol")] + [Parameter( + Mandatory = true, + ParameterSetName = WindowsDisableVMAgentWinRmHttpsParamSet, + Position = 9, + ValueFromPipelineByPropertyName = true, + HelpMessage = "Enable WinRM Https protocol")] [ValidateNotNullOrEmpty] public SwitchParameter WinRMHttps { get; set; } @@ -162,6 +221,12 @@ public class SetAzureVMOperatingSystemCommand : Microsoft.Azure.Commands.Resourc Position = 10, ValueFromPipelineByPropertyName = true, HelpMessage = "Url for WinRM certificate")] + [Parameter( + Mandatory = true, + ParameterSetName = WindowsDisableVMAgentWinRmHttpsParamSet, + Position = 10, + ValueFromPipelineByPropertyName = true, + HelpMessage = "Url for WinRM certificate")] [ValidateNotNullOrEmpty] public Uri WinRMCertificateUrl { get; set; } @@ -238,7 +303,17 @@ public override void ExecuteCmdlet() } // OS Profile - this.VM.OSProfile.WindowsConfiguration.ProvisionVMAgent = this.ProvisionVMAgent.IsPresent; + this.VM.OSProfile.WindowsConfiguration.ProvisionVMAgent = this.VM.OSProfile.WindowsConfiguration.ProvisionVMAgent; + + if (this.ProvisionVMAgent.IsPresent) + { + this.VM.OSProfile.WindowsConfiguration.ProvisionVMAgent = true; + } + + if (this.DisableVMAgent.IsPresent) + { + this.VM.OSProfile.WindowsConfiguration.ProvisionVMAgent = false; + } this.VM.OSProfile.WindowsConfiguration.EnableAutomaticUpdates = this.EnableAutoUpdate.IsPresent; diff --git a/src/ResourceManager/Compute/Commands.Compute/help/Set-AzureRmVMOperatingSystem.md b/src/ResourceManager/Compute/Commands.Compute/help/Set-AzureRmVMOperatingSystem.md index 7835b9c92ac3..9b199cf6d6a8 100644 --- a/src/ResourceManager/Compute/Commands.Compute/help/Set-AzureRmVMOperatingSystem.md +++ b/src/ResourceManager/Compute/Commands.Compute/help/Set-AzureRmVMOperatingSystem.md @@ -28,6 +28,21 @@ Set-AzureRmVMOperatingSystem [-VM] [-Windows] [-ComputerName] [-DefaultProfile ] [] ``` +### WindowsDisableVMAgent +``` +Set-AzureRmVMOperatingSystem [-VM] [-Windows] [-ComputerName] + [-Credential] [[-CustomData] ] [-DisableVMAgent] [-EnableAutoUpdate] + [[-TimeZone] ] [-WinRMHttp] [-DefaultProfile ] [] +``` + +### WindowsDisableVMAgentWinRmHttps +``` +Set-AzureRmVMOperatingSystem [-VM] [-Windows] [-ComputerName] + [-Credential] [[-CustomData] ] [-DisableVMAgent] [-EnableAutoUpdate] + [[-TimeZone] ] [-WinRMHttp] [-WinRMHttps] [-WinRMCertificateUrl] + [-DefaultProfile ] [] +``` + ### Linux ``` Set-AzureRmVMOperatingSystem [-VM] [-Linux] [-ComputerName] @@ -155,12 +170,27 @@ Accept pipeline input: True (ByPropertyName) Accept wildcard characters: False ``` +### -DisableVMAgent +Disable Provision VM Agent. + +```yaml +Type: SwitchParameter +Parameter Sets: WindowsDisableVMAgent, WindowsDisableVMAgentWinRmHttps +Aliases: + +Required: False +Position: Named +Default value: None +Accept pipeline input: False +Accept wildcard characters: False +``` + ### -EnableAutoUpdate Indicates that this cmdlet enables auto update. ```yaml Type: SwitchParameter -Parameter Sets: Windows, WindowsWinRmHttps +Parameter Sets: Windows, WindowsWinRmHttps, WindowsDisableVMAgent, WindowsDisableVMAgentWinRmHttps Aliases: Required: False @@ -205,7 +235,7 @@ Specifies the time zone for the virtual machine. ```yaml Type: String -Parameter Sets: Windows, WindowsWinRmHttps +Parameter Sets: Windows, WindowsWinRmHttps, WindowsDisableVMAgent, WindowsDisableVMAgentWinRmHttps Aliases: Required: False @@ -237,7 +267,7 @@ Indicates that the type of operating system is Windows. ```yaml Type: SwitchParameter -Parameter Sets: Windows, WindowsWinRmHttps +Parameter Sets: Windows, WindowsWinRmHttps, WindowsDisableVMAgent, WindowsDisableVMAgentWinRmHttps Aliases: Required: True @@ -253,7 +283,7 @@ This needs to be stored in a Key Vault. ```yaml Type: Uri -Parameter Sets: WindowsWinRmHttps +Parameter Sets: WindowsWinRmHttps, WindowsDisableVMAgentWinRmHttps Aliases: Required: True @@ -268,7 +298,7 @@ Indicates that this operating system uses HTTP WinRM. ```yaml Type: SwitchParameter -Parameter Sets: Windows, WindowsWinRmHttps +Parameter Sets: Windows, WindowsWinRmHttps, WindowsDisableVMAgent, WindowsDisableVMAgentWinRmHttps Aliases: Required: False @@ -283,7 +313,7 @@ Indicates that this operating system uses HTTPS WinRM. ```yaml Type: SwitchParameter -Parameter Sets: WindowsWinRmHttps +Parameter Sets: WindowsWinRmHttps, WindowsDisableVMAgentWinRmHttps Aliases: Required: True