Set-AzVMCustomScriptExtension
Adds a custom script extension to a virtual machine.
Syntax
ByNameWithContainerAndFileNamesParameterSet (Default)
Set-AzVMCustomScriptExtension
[-ResourceGroupName] <String>
[-VMName] <String>
-ContainerName <String>
-FileName <String[]>
[-Name <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>]
ByNameWithFileUriParameterSet
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>]
ByParentObjectWithContainerAndFileNamesParameterSet
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>]
ByParentObjectWithFileUriParameterSet
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>]
ByResourceIdWithContainerAndFileNamesParameterSet
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>]
ByResourceIdWithFileUriParameterSet
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.
Parameter properties
Type: String
Default value: None
Supports wildcards: False
DontShow: False
Parameter sets
(All)
Position: Named
Mandatory: False
Value from pipeline: False
Value from pipeline by property name: True
Value from remaining arguments: False
-Confirm
Prompts you for confirmation before running the cmdlet.
Parameter properties
Type: SwitchParameter
Default value: False
Supports wildcards: False
DontShow: False
Aliases: cf
Parameter sets
(All)
Position: Named
Mandatory: False
Value from pipeline: False
Value from pipeline by property name: False
Value from remaining arguments: False
-ContainerName
Specifies the name of the Azure storage container where this cmdlet stores the script.
Parameter properties
Type: String
Default value: None
Supports wildcards: False
DontShow: False
Parameter sets
ByNameWithContainerAndFileNamesParameterSet
Position: Named
Mandatory: True
Value from pipeline: False
Value from pipeline by property name: True
Value from remaining arguments: False
-DefaultProfile
The credentials, account, tenant, and subscription used for communication with azure.
Parameter properties
Type: IAzureContextContainer
Default value: None
Supports wildcards: False
DontShow: False
Aliases: AzContext, AzureRmContext, AzureCredential
Parameter sets
(All)
Position: Named
Mandatory: False
Value from pipeline: False
Value from pipeline by property name: False
Value from remaining arguments: False
-DisableAutoUpgradeMinorVersion
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.
Parameter properties
Type: SwitchParameter
Default value: None
Supports wildcards: False
DontShow: False
Parameter sets
(All)
Position: Named
Mandatory: False
Value from pipeline: False
Value from pipeline by property name: True
Value from remaining arguments: 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.
Parameter properties
Type: String [ ]
Default value: None
Supports wildcards: False
DontShow: False
Parameter sets
ByNameWithContainerAndFileNamesParameterSet
Position: Named
Mandatory: True
Value from pipeline: False
Value from pipeline by property name: True
Value from remaining arguments: False
-FileUri
Specifies the URI of the script file.
Parameter properties
Type: String [ ]
Default value: None
Supports wildcards: False
DontShow: False
Parameter sets
ByNameWithFileUriParameterSet
Position: Named
Mandatory: False
Value from pipeline: False
Value from pipeline by property name: True
Value from remaining arguments: 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.
Parameter properties
Type: String
Default value: None
Supports wildcards: False
DontShow: False
Parameter sets
(All)
Position: Named
Mandatory: False
Value from pipeline: False
Value from pipeline by property name: True
Value from remaining arguments: False
VM extension object.
ByInputObjectWithContainerAndFileNamesParameterSet
Position: Named
Mandatory: True
Value from pipeline: True
Value from pipeline by property name: False
Value from remaining arguments: False
ByInputObjectWithFileUriParameterSet
Position: Named
Mandatory: True
Value from pipeline: True
Value from pipeline by property name: False
Value from remaining arguments: False
-Location
Specifies the location of the virtual machine.
Parameter properties
Type: String
Default value: None
Supports wildcards: False
DontShow: False
Parameter sets
(All)
Position: Named
Mandatory: False
Value from pipeline: False
Value from pipeline by property name: True
Value from remaining arguments: False
-Name
Specifies the name of the custom script extension.
Parameter properties
Type: String
Default value: None
Supports wildcards: False
DontShow: False
Aliases: ExtensionName
Parameter sets
ByNameWithContainerAndFileNamesParameterSet
Position: Named
Mandatory: False
Value from pipeline: False
Value from pipeline by property name: True
Value from remaining arguments: False
ByNameWithFileUriParameterSet
Position: Named
Mandatory: False
Value from pipeline: False
Value from pipeline by property name: True
Value from remaining arguments: 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.
Parameter properties
Type: SwitchParameter
Default value: None
Supports wildcards: False
DontShow: False
Parameter sets
(All)
Position: Named
Mandatory: False
Value from pipeline: False
Value from pipeline by property name: False
Value from remaining arguments: False
-ResourceGroupName
Specifies the name of the resource group of the virtual machine.
Parameter properties
Type: String
Default value: None
Supports wildcards: False
DontShow: False
Parameter sets
ByNameWithContainerAndFileNamesParameterSet
Position: 0
Mandatory: True
Value from pipeline: False
Value from pipeline by property name: True
Value from remaining arguments: False
ByNameWithFileUriParameterSet
Position: 0
Mandatory: True
Value from pipeline: False
Value from pipeline by property name: True
Value from remaining arguments: False
-ResourceId
VM extension ResourceID.
Parameter properties
Type: String
Default value: None
Supports wildcards: False
DontShow: False
Parameter sets
ByResourceIdWithContainerAndFileNamesParameterSet
Position: Named
Mandatory: True
Value from pipeline: False
Value from pipeline by property name: True
Value from remaining arguments: False
ByResourceIdWithFileUriParameterSet
Position: Named
Mandatory: True
Value from pipeline: False
Value from pipeline by property name: True
Value from remaining arguments: False
-Run
Specifies the command to use that runs your script.
Parameter properties
Type: String
Default value: None
Supports wildcards: False
DontShow: False
Aliases: RunFile, Command
Parameter sets
(All)
Position: Named
Mandatory: False
Value from pipeline: False
Value from pipeline by property name: True
Value from remaining arguments: 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.
Parameter properties
Type: SwitchParameter
Default value: None
Supports wildcards: False
DontShow: False
Parameter sets
(All)
Position: Named
Mandatory: False
Value from pipeline: False
Value from pipeline by property name: True
Value from remaining arguments: False
-StorageAccountKey
Specifies the key for the Azure storage container.
Parameter properties
Type: String
Default value: None
Supports wildcards: False
DontShow: False
Parameter sets
ByNameWithContainerAndFileNamesParameterSet
Position: Named
Mandatory: False
Value from pipeline: False
Value from pipeline by property name: True
Value from remaining arguments: False
-StorageAccountName
Specifies the name of the Azure storage account where this cmdlet stores the script.
Parameter properties
Type: String
Default value: None
Supports wildcards: False
DontShow: False
Parameter sets
ByNameWithContainerAndFileNamesParameterSet
Position: Named
Mandatory: False
Value from pipeline: False
Value from pipeline by property name: True
Value from remaining arguments: False
-StorageEndpointSuffix
Specifies the storage endpoint suffix.
Parameter properties
Type: String
Default value: None
Supports wildcards: False
DontShow: False
Parameter sets
ByNameWithContainerAndFileNamesParameterSet
Position: Named
Mandatory: False
Value from pipeline: False
Value from pipeline by property name: True
Value from remaining arguments: 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.
Parameter properties
Type: String
Default value: None
Supports wildcards: False
DontShow: False
Aliases: HandlerVersion, Version
Parameter sets
(All)
Position: Named
Mandatory: False
Value from pipeline: False
Value from pipeline by property name: True
Value from remaining arguments: False
-VMName
Specifies the name of a virtual machine.
This cmdlet adds the custom script extension for the virtual machine that this parameter specifies.
Parameter properties
Type: String
Default value: None
Supports wildcards: False
DontShow: False
Aliases: ResourceName
Parameter sets
ByNameWithContainerAndFileNamesParameterSet
Position: 1
Mandatory: True
Value from pipeline: False
Value from pipeline by property name: True
Value from remaining arguments: False
ByNameWithFileUriParameterSet
Position: 1
Mandatory: True
Value from pipeline: False
Value from pipeline by property name: True
Value from remaining arguments: False
-VMObject
VM object.
Parameter properties
Type: PSVirtualMachine
Default value: None
Supports wildcards: False
DontShow: False
Parameter sets
ByParentObjectWithContainerAndFileNamesParameterSet
Position: Named
Mandatory: True
Value from pipeline: True
Value from pipeline by property name: False
Value from remaining arguments: False
ByParentObjectWithFileUriParameterSet
Position: Named
Mandatory: True
Value from pipeline: True
Value from pipeline by property name: False
Value from remaining arguments: False
-WhatIf
Shows what would happen if the cmdlet runs.
The cmdlet is not run.
Parameter properties
Type: SwitchParameter
Default value: False
Supports wildcards: False
DontShow: False
Aliases: wi
Parameter sets
(All)
Position: Named
Mandatory: False
Value from pipeline: False
Value from pipeline by property name: False
Value from remaining arguments: False
CommonParameters
This cmdlet supports the common parameters: -Debug, -ErrorAction, -ErrorVariable,
-InformationAction, -InformationVariable, -OutBuffer, -OutVariable, -PipelineVariable,
-ProgressAction, -Verbose, -WarningAction, and -WarningVariable. For more information, see
about_CommonParameters .
Outputs