Deploy: Azure PowerShell

Azure Pipelines

Run a PowerShell script within an Azure environment

YAML snippet

# Azure PowerShell
# Run a PowerShell script within an Azure environment
- task: AzurePowerShell@3
    #azureConnectionType: 'ConnectedServiceNameARM' # Optional. Options: connectedServiceName, connectedServiceNameARM
    #azureClassicSubscription: # Required when azureConnectionType == ConnectedServiceName
    #azureSubscription: # Required when azureConnectionType == ConnectedServiceNameARM
    #scriptType: 'FilePath' # Optional. Options: filePath, inlineScript
    #scriptPath: # Optional
    #inline: '# You can write your azure powershell scripts inline here. # You can also pass predefined and custom variables to this script using arguments' # Optional
    #scriptArguments: # Optional
    #errorActionPreference: 'stop' # Optional. Options: stop, continue, silentlyContinue
    #failOnStandardError: false # Optional
    #azurePowerShellVersion: 'OtherVersion' # Optional. Options: latestVersion, otherVersion
    #preferredAzurePowerShellVersion: # Required when azurePowerShellVersion == OtherVersion


Azure Connection Type(Optional)
Azure Classic Subscription(Required) Azure Classic subscription to configure before running PowerShell
Azure Subscription(Required) Azure Resource Manager subscription to configure before running PowerShell
Script Type(Optional) Type of the script: File Path or Inline Script
Script Path(Optional) Path of the script. Should be fully qualified path or relative to the default working directory.
Inline Script(Optional) Enter the script to execute.
Script Arguments(Optional) Additional parameters to pass to PowerShell. Can be either ordinal or named parameters.
ErrorActionPreference(Optional) Select the value of the ErrorActionPreference variable for executing the script.
Fail on Standard Error(Optional) If this is true, this task will fail if any errors are written to the error pipeline, or if any data is written to the Standard Error stream.
Azure PowerShell Version(Optional) In case of Microsoft-hosted agents, the supported Azure PowerShell Versions are: 2.1.0, 3.8.0, 4.2.1 and 5.1.1 (Hosted VS2017 pool), 3.6.0 (Hosted pool). To pick the latest version available on the agent, select "Latest installed version". For self-hosted agents you can specify preferred version of Azure PowerShell using "Specify version"
Preferred Azure PowerShell Version(Required) Preferred Azure PowerShell Version needs to be a proper semantic version eg. 1.2.3. Regex like 2.*,2.3.* is not supported. The Hosted VS2017 pool currently supports versions: 2.1.0, 3.8.0, 4.2.1, 5.1.1
Control options

Open source

This task is open source on GitHub. Feedback and contributions are welcome.

Q & A