Azure PowerShell task

Azure Pipelines

Use this task in a build or release pipeline to run a PowerShell script within an Azure environment.

YAML snippet

# Azure PowerShell
# Run a PowerShell script within an Azure environment
- task: AzurePowerShell@4
    #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 version. 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.
Control options

Open source

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