Set-AzVMCustomScriptExtension
Adds a custom script extension to a virtual machine.
Syntax
Set-AzVMCustomScriptExtension
[-ResourceGroupName] <String>
[-VMName] <String>
[-Name <String>]
-ContainerName <String>
-FileName <String[]>
[-StorageAccountName <String>]
[-StorageEndpointSuffix <String>]
[-StorageAccountKey <String>]
[-Run <String>]
[-Argument <String>]
[-SecureExecution]
[-TypeHandlerVersion <String>]
[-Location <String>]
[-DisableAutoUpgradeMinorVersion]
[-ForceRerun <String>]
[-NoWait]
[-DefaultProfile <IAzureContextContainer>]
[-WhatIf]
[-Confirm]
[<CommonParameters>]
Set-AzVMCustomScriptExtension
[-ResourceGroupName] <String>
[-VMName] <String>
[-Name <String>]
[-FileUri <String[]>]
[-Run <String>]
[-Argument <String>]
[-SecureExecution]
[-TypeHandlerVersion <String>]
[-Location <String>]
[-DisableAutoUpgradeMinorVersion]
[-ForceRerun <String>]
[-NoWait]
[-DefaultProfile <IAzureContextContainer>]
[-WhatIf]
[-Confirm]
[<CommonParameters>]
Set-AzVMCustomScriptExtension
-Name <String>
-VMObject <PSVirtualMachine>
-ContainerName <String>
-FileName <String[]>
[-StorageAccountName <String>]
[-StorageEndpointSuffix <String>]
[-StorageAccountKey <String>]
[-Run <String>]
[-Argument <String>]
[-SecureExecution]
[-TypeHandlerVersion <String>]
[-Location <String>]
[-DisableAutoUpgradeMinorVersion]
[-ForceRerun <String>]
[-NoWait]
[-DefaultProfile <IAzureContextContainer>]
[-WhatIf]
[-Confirm]
[<CommonParameters>]
Set-AzVMCustomScriptExtension
-Name <String>
-VMObject <PSVirtualMachine>
[-FileUri <String[]>]
[-Run <String>]
[-Argument <String>]
[-SecureExecution]
[-TypeHandlerVersion <String>]
[-Location <String>]
[-DisableAutoUpgradeMinorVersion]
[-ForceRerun <String>]
[-NoWait]
[-DefaultProfile <IAzureContextContainer>]
[-WhatIf]
[-Confirm]
[<CommonParameters>]
Set-AzVMCustomScriptExtension
-ResourceId <String>
-ContainerName <String>
-FileName <String[]>
[-StorageAccountName <String>]
[-StorageEndpointSuffix <String>]
[-StorageAccountKey <String>]
[-Run <String>]
[-Argument <String>]
[-SecureExecution]
[-TypeHandlerVersion <String>]
[-Location <String>]
[-DisableAutoUpgradeMinorVersion]
[-ForceRerun <String>]
[-NoWait]
[-DefaultProfile <IAzureContextContainer>]
[-WhatIf]
[-Confirm]
[<CommonParameters>]
Set-AzVMCustomScriptExtension
-ResourceId <String>
[-FileUri <String[]>]
[-Run <String>]
[-Argument <String>]
[-SecureExecution]
[-TypeHandlerVersion <String>]
[-Location <String>]
[-DisableAutoUpgradeMinorVersion]
[-ForceRerun <String>]
[-NoWait]
[-DefaultProfile <IAzureContextContainer>]
[-WhatIf]
[-Confirm]
[<CommonParameters>]
Set-AzVMCustomScriptExtension
-InputObject <VirtualMachineCustomScriptExtensionContext>
-ContainerName <String>
-FileName <String[]>
[-StorageAccountName <String>]
[-StorageEndpointSuffix <String>]
[-StorageAccountKey <String>]
[-Run <String>]
[-Argument <String>]
[-SecureExecution]
[-TypeHandlerVersion <String>]
[-Location <String>]
[-DisableAutoUpgradeMinorVersion]
[-ForceRerun <String>]
[-NoWait]
[-DefaultProfile <IAzureContextContainer>]
[-WhatIf]
[-Confirm]
[<CommonParameters>]
Set-AzVMCustomScriptExtension
-InputObject <VirtualMachineCustomScriptExtensionContext>
[-FileUri <String[]>]
[-Run <String>]
[-Argument <String>]
[-SecureExecution]
[-TypeHandlerVersion <String>]
[-Location <String>]
[-DisableAutoUpgradeMinorVersion]
[-ForceRerun <String>]
[-NoWait]
[-DefaultProfile <IAzureContextContainer>]
[-WhatIf]
[-Confirm]
[<CommonParameters>]
Description
The Set-AzVMCustomScriptExtension cmdlet adds a custom script Virtual Machine Extension to a virtual machine. This extension lets you run your own scripts on the virtual machine.
Examples
Example 1: Add a custom script
Set-AzVMCustomScriptExtension -ResourceGroupName "ResourceGroup11" -Location "Central US" -VMName "VirtualMachine07" -Name "ContosoTest" -TypeHandlerVersion "1.1" -StorageAccountName "Contoso" -StorageAccountKey <StorageKey> -FileName "ContosoScript.exe" -ContainerName "Scripts"
This command adds a custom script to the virtual machine named VirtualMachine07. The script file is contososcript.exe.
Example 2
Adds a custom script extension to a virtual machine. (autogenerated)
Set-AzVMCustomScriptExtension -Argument <String> -ContainerName 'Scripts' -DefaultProfile <IAzureContextContainer> -FileName 'ContosoScript.exe' -Location 'Central US' -Name 'ContosoTest' -ResourceGroupName 'ResourceGroup11' -Run 'myScript.ps1' -SecureExecution -StorageAccountKey <String> -StorageAccountName 'Contoso' -TypeHandlerVersion '1.1' -VMName 'VirtualMachine07'
Parameters
-Argument
Specifies arguments that the script extension passes to the script.
Type: | String |
Position: | Named |
Default value: | None |
Required: | False |
Accept pipeline input: | True |
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 |
-ContainerName
Specifies the name of the Azure storage container where this cmdlet stores the script.
Type: | String |
Position: | Named |
Default value: | None |
Required: | True |
Accept pipeline input: | True |
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
Type: | SwitchParameter |
Position: | Named |
Default value: | None |
Required: | False |
Accept pipeline input: | True |
Accept wildcard characters: | False |
-FileName
Specifies the name of the script file. If the file is stored in Azure Blob storage, the file name value is case-sensitive. File names of files stored in Azure File storage are not case-sensitive.
Type: | String[] |
Position: | Named |
Default value: | None |
Required: | True |
Accept pipeline input: | True |
Accept wildcard characters: | False |
-FileUri
Specifies the URI of the script file.
Type: | String[] |
Position: | Named |
Default value: | None |
Required: | False |
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 |
-InputObject
VM extension object.
Type: | VirtualMachineCustomScriptExtensionContext |
Position: | Named |
Default value: | None |
Required: | True |
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 the custom script 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 |
-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 |
-ResourceId
VM extension ResourceID.
Type: | String |
Position: | Named |
Default value: | None |
Required: | True |
Accept pipeline input: | True |
Accept wildcard characters: | False |
-Run
Specifies the command to use that runs your script.
Type: | String |
Aliases: | RunFile, Command |
Position: | Named |
Default value: | None |
Required: | False |
Accept pipeline input: | True |
Accept wildcard characters: | False |
-SecureExecution
Indicates that this cmdlet makes sure that the value of the Run parameter is not logged on the server or returned to the user by using the GET extension API. The value of Run might contain secrets or passwords to be passed to the script file securely.
Type: | SwitchParameter |
Position: | Named |
Default value: | None |
Required: | False |
Accept pipeline input: | True |
Accept wildcard characters: | False |
-StorageAccountKey
Specifies the key for the Azure storage container.
Type: | String |
Position: | Named |
Default value: | None |
Required: | False |
Accept pipeline input: | True |
Accept wildcard characters: | False |
-StorageAccountName
Specifies the name of the Azure storage account where this cmdlet stores the script.
Type: | String |
Position: | Named |
Default value: | None |
Required: | False |
Accept pipeline input: | True |
Accept wildcard characters: | False |
-StorageEndpointSuffix
Specifies the storage endpoint suffix.
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. To obtain the version, run the Get-AzVMExtensionImage cmdlet with a value of Microsoft.Compute for the PublisherName parameter and CustomScriptExtension for the Type parameter.
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 adds the custom script extension 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 |
-VMObject
VM object.
Type: | PSVirtualMachine |
Position: | Named |
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[]
Outputs
Related Links
Azure PowerShell