Set-​Azure​Rm​VM​Extension

Updates extension properties or adds an extension to a virtual machine.

Syntax

Set-AzureRmVMExtension
   [-ResourceGroupName] <String>
   [-VMName] <String>
   [-DisableAutoUpgradeMinorVersion]
   -ExtensionType <String>
   [-ForceRerun <String>]
   [-Location <String>]
   [-Name <String>]
   [-ProtectedSettings <Hashtable>]
   -Publisher <String>
   [-Settings <Hashtable>]
   [-TypeHandlerVersion <String>]
   [-Confirm]
   [-WhatIf]
   [<CommonParameters>]
Set-AzureRmVMExtension
   [-ResourceGroupName] <String>
   [-VMName] <String>
   [-DisableAutoUpgradeMinorVersion]
   -ExtensionType <String>
   [-ForceRerun <String>]
   [-Location <String>]
   [-Name <String>]
   [-ProtectedSettingString <String>]
   -Publisher <String>
   [-SettingString <String>]
   [-TypeHandlerVersion <String>]
   [-Confirm]
   [-WhatIf]
   [<CommonParameters>]

Description

The Set-AzureRmVMExtension cmdlet updates properties for existing Virtual Machine Extensions or adds an extension to a virtual machine.

Examples

Example 1: Modify settings by using hash tables

PS C:\>$Settings = @{"fileUris" = "[]"; "commandToExecute" = ""};
PS C:\> $ProtectedSettings = @{"storageAccountName" = $stoname; "storageAccountKey" = $stokey};
PS C:\> Set-AzureRmVMExtension -ResourceGroupName "ResourceGroup11" -Location "West US" -VMName "VirtualMachine22" -Name "ContosoTest" -Publisher "Contoso.Compute" -Type "CustomScriptExtension" -TypeHandlerVersion "1.1" -Settings $Settings -ProtectedSettings $ProtectedSettings;

The first two commands use standard Windows PowerShell syntax to create hash tables, and then stores those hash tables in the $Settings and $ProtectedSettings variables. For more information, type Get-Help about_Hash_Tables. The second command includes two values previously created and stored in variables.

The final command modifies an extension of the virtual machine named VirtualMachine22 in ResourceGroup11 according to the contents of $Settings and $ProtectedSettings. The command specifies other required information that includes the publisher and the extension type.

Example 2: Modify settings by using strings

PS C:\>$SettingsString = '{"fileUris":[],"commandToExecute":""}';
PS C:\> $ProtectedSettingsString = '{"storageAccountName":"' + $stoname + '","storageAccountKey":"' + $stokey + '"}';
PS C:\> Set-AzureRmVMExtension -ResourceGroupName "ResourceGroup11" -Location "West US" -VMName "VirtualMachine22" -Name "CustomScriptExtension" -Publisher "Contoso.Compute" -Type "CustomScriptExtension" -TypeHandlerVersion "1.1" -SettingString $SettingsString -ProtectedSettingString $ProtectedSettingsString ;

The first two commands create strings that contain settings, and then stores them in the $SettingsString and $ProtectedSettingsString variables.

The final command modifies an extension of the virtual machine named VirtualMachine22 in ResourceGroup11 according to the contents of $SettingsString and $ProtectedSettingsString. The command specifies other required information that includes the publisher and the extension type.

Required Parameters

-ExtensionType

Specifies the extension type.

Type:String
Aliases:Type
Position:Named
Default value:None
Accept pipeline input:True (ByPropertyName)
Accept wildcard characters:False
-Publisher

Specifies the name of the extension publisher. The publisher provides a name when the publisher registers an extension.

Type:String
Position:Named
Default value:None
Accept pipeline input:True (ByPropertyName)
Accept wildcard characters:False
-ResourceGroupName

Specifies the name of the resource group of the virtual machine.

Type:String
Position:1
Default value:None
Accept pipeline input:True (ByPropertyName)
Accept wildcard characters:False
-VMName

Specifies the name of a virtual machine. This cmdlet modifies extensions for the virtual machine that this parameter specifies.

Type:String
Aliases:ResourceName
Position:2
Default value:None
Accept pipeline input:True (ByPropertyName)
Accept wildcard characters:False

Optional Parameters

-Confirm

Prompts you for confirmation before running the cmdlet.

Type:SwitchParameter
Aliases:cf
Position:Named
Default value:False
Accept pipeline input:False
Accept wildcard characters:False
-DisableAutoUpgradeMinorVersion

Indicates that this cmdlet prevents the Azure guest agent from automatically updating the extensions to a newer minor version. By default, this cmdlet enables the guest agent to update the extensions.

Type:SwitchParameter
Position:Named
Default value:None
Accept pipeline input:True (ByPropertyName)
Accept wildcard characters:False
-ForceRerun

Indicates that this cmdlet forces a rerun of the same extension configuration on the virtual machine without uninstalling and reinstalling the extension. The value can be any string different from the current value.If forceUpdateTag is not changed, updates to public or protected settings are still applied by the handler.

Type:String
Position:Named
Default value:None
Accept pipeline input:True (ByPropertyName)
Accept wildcard characters:False
-Location

Specifies the location of the virtual machine.

Type:String
Position:Named
Default value:None
Accept pipeline input:True (ByPropertyName)
Accept wildcard characters:False
-Name

Specifies the name of an extension.

Type:String
Aliases:ExtensionName
Position:Named
Default value:None
Accept pipeline input:True (ByPropertyName)
Accept wildcard characters:False
-ProtectedSettingString

Specifies private configuration for the extension, as a string. This cmdlet encrypts the private configuration.

Type:String
Position:Named
Default value:None
Accept pipeline input:True (ByPropertyName)
Accept wildcard characters:False
-ProtectedSettings

Specifies private configuration for the extension, as a hash table. This cmdlet encrypts the private configuration.

Type:Hashtable
Position:Named
Default value:None
Accept pipeline input:True (ByPropertyName)
Accept wildcard characters:False
-SettingString

Specifies public configuration for the extension, as a string. This cmdlet does not encrypt public configuration.

Type:String
Position:Named
Default value:None
Accept pipeline input:True (ByPropertyName)
Accept wildcard characters:False
-Settings

Specifies public configuration for the extension, as a hash table. This cmdlet does not encrypt public configuration.

Type:Hashtable
Position:Named
Default value:None
Accept pipeline input:True (ByPropertyName)
Accept wildcard characters:False
-TypeHandlerVersion

Specifies the version of the extension to use for this virtual machine.

Type:String
Aliases:HandlerVersion, Version
Position:Named
Default value:None
Accept pipeline input:True (ByPropertyName)
Accept wildcard characters:False
-WhatIf

Shows what would happen if the cmdlet runs.The cmdlet is not run.

Type:SwitchParameter
Aliases:wi
Position:Named
Default value:False
Accept pipeline input:False
Accept wildcard characters:False