編集

次の方法で共有


Set-AzVMExtension

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

Syntax

Set-AzVMExtension
   -Publisher <String>
   -ExtensionType <String>
   [-Settings <Hashtable>]
   [-ProtectedSettings <Hashtable>]
   [-EnableAutomaticUpgrade <Boolean>]
   [-AsJob]
   [-ResourceGroupName] <String>
   [-VMName] <String>
   -Name <String>
   [-TypeHandlerVersion <String>]
   [-Location <String>]
   [-DisableAutoUpgradeMinorVersion]
   [-ForceRerun <String>]
   [-NoWait]
   [-DefaultProfile <IAzureContextContainer>]
   [-WhatIf]
   [-Confirm]
   [<CommonParameters>]
Set-AzVMExtension
   -Publisher <String>
   -ExtensionType <String>
   [-SettingString <String>]
   [-ProtectedSettingString <String>]
   [-EnableAutomaticUpgrade <Boolean>]
   [-AsJob]
   [-ResourceGroupName] <String>
   [-VMName] <String>
   -Name <String>
   [-TypeHandlerVersion <String>]
   [-Location <String>]
   [-DisableAutoUpgradeMinorVersion]
   [-ForceRerun <String>]
   [-NoWait]
   [-DefaultProfile <IAzureContextContainer>]
   [-WhatIf]
   [-Confirm]
   [<CommonParameters>]

Description

The Set-AzVMExtension 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

$Settings = @{"fileUris" = "[]"; "commandToExecute" = ""};
$ProtectedSettings = @{"storageAccountName" = $stoname; "storageAccountKey" = $stokey};
Set-AzVMExtension -ResourceGroupName "ResourceGroup11" -Location "West US" -VMName "VirtualMachine22" -Name "ContosoTest" -Publisher "Contoso.Compute" -ExtensionType "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

$SettingsString = '{"fileUris":[],"commandToExecute":""}';
$ProtectedSettingsString = '{"storageAccountName":"' + $stoname + '","storageAccountKey":"' + $stokey + '"}';
Set-AzVMExtension -ResourceGroupName "ResourceGroup11" -Location "West US" -VMName "VirtualMachine22" -Name "CustomScriptExtension" -Publisher "Contoso.Compute" -ExtensionType "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.

Parameters

-AsJob

Run cmdlet in the background

Type:SwitchParameter
Position:Named
Default value:None
Required:False
Accept pipeline input:False
Accept wildcard characters:False

-Confirm

Prompts you for confirmation before running the cmdlet.

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

-DefaultProfile

The credentials, account, tenant, and subscription used for communication with azure.

Type:IAzureContextContainer
Aliases:AzContext, AzureRmContext, AzureCredential
Position:Named
Default value:None
Required: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
Required:False
Accept pipeline input:True
Accept wildcard characters:False

-EnableAutomaticUpgrade

Indicates whether the extension should be automatically upgraded by the platform if there is a newer version of the extension available.

Type:Nullable<T>[Boolean]
Position:Named
Default value:None
Required:False
Accept pipeline input:False
Accept wildcard characters:False

-ExtensionType

Specifies the extension type.

Type:String
Aliases:Type
Position:Named
Default value:None
Required:True
Accept pipeline input:True
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
Required:False
Accept pipeline input:True
Accept wildcard characters:False

-Location

Specifies the location of the virtual machine.

Type:String
Position:Named
Default value:None
Required:False
Accept pipeline input:True
Accept wildcard characters:False

-Name

Specifies the name of an extension.

Type:String
Aliases:ExtensionName
Position:Named
Default value:None
Required:True
Accept pipeline input:True
Accept wildcard characters:False

-NoWait

Starts the operation and returns immediately, before the operation is completed. In order to determine if the operation has successfully been completed, use some other mechanism.

Type:SwitchParameter
Position:Named
Default value:None
Required:False
Accept pipeline input:False
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
Required:False
Accept pipeline input:True
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
Required:False
Accept pipeline input:True
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
Required:True
Accept pipeline input:True
Accept wildcard characters:False

-ResourceGroupName

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

Type:String
Position:0
Default value:None
Required:True
Accept pipeline input:True
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
Required:False
Accept pipeline input:True
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
Required:False
Accept pipeline input:True
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
Required:False
Accept pipeline input:True
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:1
Default value:None
Required:True
Accept pipeline input:True
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
Required:False
Accept pipeline input:False
Accept wildcard characters:False

Inputs

String

Hashtable

SwitchParameter

Outputs

PSAzureOperationResponse