title | description | ms.date | monikerRange |
---|---|---|---|
AzurePowerShell@3 - Azure PowerShell v3 task |
Run a PowerShell script within an Azure environment (task version 3). |
01/29/2025 |
>=azure-pipelines-2019 |
:::moniker range="=azure-pipelines"
Use this task to run a PowerShell script within an Azure environment. The Azure context is authenticated with the provided Azure Resource Manager service connection.
This version of the task is deprecated; use AzurePowerShell@5.
:::moniker-end
:::moniker range=">=azure-pipelines-2019 <=azure-pipelines-2022.2"
Use this task to run a PowerShell script within an Azure environment. The Azure context is authenticated with the provided Azure Resource Manager service connection.
:::moniker-end
:::moniker range=">=azure-pipelines-2022.1"
# Azure PowerShell v3
# Run a PowerShell script within an Azure environment.
- task: AzurePowerShell@3
inputs:
#azureConnectionType: 'ConnectedServiceNameARM' # 'ConnectedServiceName' | 'ConnectedServiceNameARM'. Alias: ConnectedServiceNameSelector. Azure Connection Type. Default: ConnectedServiceNameARM.
#azureClassicSubscription: # string. Alias: ConnectedServiceName. Required when ConnectedServiceNameSelector = ConnectedServiceName. Azure Classic Subscription.
azureSubscription: # string. Alias: ConnectedServiceNameARM. Required when ConnectedServiceNameSelector = ConnectedServiceNameARM. Azure Subscription.
#ScriptType: 'FilePath' # 'FilePath' | 'InlineScript'. Script Type. Default: FilePath.
#ScriptPath: # string. Optional. Use when ScriptType = FilePath. Script Path.
#Inline: # string. Optional. Use when ScriptType = InlineScript. Inline Script.
#ScriptArguments: # string. Optional. Use when ScriptType = FilePath. Script Arguments.
#errorActionPreference: 'stop' # 'stop' | 'continue' | 'silentlyContinue'. ErrorActionPreference. Default: stop.
#FailOnStandardError: false # boolean. Fail on Standard Error. Default: false.
# Azure PowerShell version options
#azurePowerShellVersion: 'OtherVersion' # 'LatestVersion' | 'OtherVersion'. Alias: TargetAzurePs. Azure PowerShell Version. Default: OtherVersion.
preferredAzurePowerShellVersion: # string. Alias: CustomTargetAzurePs. Required when TargetAzurePs = OtherVersion. Preferred Azure PowerShell Version.
# Advanced
#validateScriptSignature: false # boolean. Optional. Use when ScriptType = FilePath. Validate script signature. Default: false.
:::moniker-end
:::moniker range=">=azure-pipelines-2019 <=azure-pipelines-2022"
# Azure PowerShell v3
# Run a PowerShell script within an Azure environment.
- task: AzurePowerShell@3
inputs:
#azureConnectionType: 'ConnectedServiceNameARM' # 'ConnectedServiceName' | 'ConnectedServiceNameARM'. Alias: ConnectedServiceNameSelector. Azure Connection Type. Default: ConnectedServiceNameARM.
#azureClassicSubscription: # string. Alias: ConnectedServiceName. Required when ConnectedServiceNameSelector = ConnectedServiceName. Azure Classic Subscription.
azureSubscription: # string. Alias: ConnectedServiceNameARM. Required when ConnectedServiceNameSelector = ConnectedServiceNameARM. Azure Subscription.
#ScriptType: 'FilePath' # 'FilePath' | 'InlineScript'. Script Type. Default: FilePath.
#ScriptPath: # string. Optional. Use when ScriptType = FilePath. Script Path.
#Inline: # string. Optional. Use when ScriptType = InlineScript. Inline Script.
#ScriptArguments: # string. Optional. Use when ScriptType = FilePath. Script Arguments.
#errorActionPreference: 'stop' # 'stop' | 'continue' | 'silentlyContinue'. ErrorActionPreference. Default: stop.
#FailOnStandardError: false # boolean. Fail on Standard Error. Default: false.
# Azure PowerShell version options
#azurePowerShellVersion: 'OtherVersion' # 'LatestVersion' | 'OtherVersion'. Alias: TargetAzurePs. Azure PowerShell Version. Default: OtherVersion.
preferredAzurePowerShellVersion: # string. Alias: CustomTargetAzurePs. Required when TargetAzurePs = OtherVersion. Preferred Azure PowerShell Version.
:::moniker-end
:::moniker range=">=azure-pipelines-2019"
azureConnectionType
- Azure Connection Type
Input alias: ConnectedServiceNameSelector
. string
. Allowed values: ConnectedServiceName
(Azure Classic), ConnectedServiceNameARM
(Azure Resource Manager). Default value: ConnectedServiceNameARM
.
:::moniker-end
:::moniker range=">=azure-pipelines-2019"
azureClassicSubscription
- Azure Classic Subscription
Input alias: ConnectedServiceName
. string
. Required when ConnectedServiceNameSelector = ConnectedServiceName
.
The Azure Classic subscription to configure before running PowerShell.
:::moniker-end
:::moniker range=">=azure-pipelines-2019"
azureSubscription
- Azure Subscription
Input alias: ConnectedServiceNameARM
. string
. Required when ConnectedServiceNameSelector = ConnectedServiceNameARM
.
The Azure Resource Manager subscription to configure before running PowerShell.
:::moniker-end
:::moniker range=">=azure-pipelines-2019"
ScriptType
- Script Type
string
. Allowed values: FilePath
(Script File Path), InlineScript
(Inline Script). Default value: FilePath
.
The type of the script: file path or inline.
:::moniker-end
:::moniker range=">=azure-pipelines-2019"
ScriptPath
- Script Path
string
. Optional. Use when ScriptType = FilePath
.
The path of the script. This should be a fully qualified path or one relative to the default working directory.
:::moniker-end
:::moniker range=">=azure-pipelines-2019"
Inline
- Inline Script
string
. Optional. Use when ScriptType = InlineScript
. Default value: # You can write your azure powershell scripts inline here. \n# You can also pass predefined and custom variables to this script using arguments
.
Specifes the script to execute. The maximum supported inline script length is 5000 characters. Use a script from a file if you want to use a longer script.
:::moniker-end
:::moniker range=">=azure-pipelines-2019"
ScriptArguments
- Script Arguments
string
. Optional. Use when ScriptType = FilePath
.
The additional parameters to pass to PowerShell. These can be either ordinal or named parameters.
:::moniker-end
:::moniker range=">=azure-pipelines-2019"
errorActionPreference
- ErrorActionPreference
string
. Allowed values: stop
, continue
, silentlyContinue
. Default value: stop
.
Selects the value of the ErrorActionPreference
variable for executing the script.
:::moniker-end
:::moniker range=">=azure-pipelines-2019"
FailOnStandardError
- Fail on Standard Error
boolean
. Default value: false
.
When 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.
:::moniker-end
:::moniker range=">=azure-pipelines-2019"
azurePowerShellVersion
- Azure PowerShell Version
Input alias: TargetAzurePs
. string
. Allowed values: LatestVersion
(Latest installed version), OtherVersion
(Specify other version). Default value: OtherVersion
.
In case of hosted agents, the supported Azure PowerShell Versions are 2.1.0
, 3.8.0
, 4.2.1
, 5.1.1
and 6.7.0
.
To pick the latest version available on the agent, select LatestVersion
(Latest installed version).
For private agents, you can specify a preferred version of Azure PowerShell using OtherVersion
(Specify other version).
:::moniker-end
:::moniker range=">=azure-pipelines-2019"
preferredAzurePowerShellVersion
- Preferred Azure PowerShell Version
Input alias: CustomTargetAzurePs
. string
. Required when TargetAzurePs = OtherVersion
.
The preferred Azure PowerShell Version needs to be a proper semantic version eg. 1.2.3.
. Regex like 2.\*,2.3.\*
is not supported. Hosted agents currently supports Azure module versions 2.1.0
, 3.8.0
, 4.2.1
, 5.1.1
and AzureRM module versions 2.1.0
, 3.8.0
, 4.2.1
, 5.1.1
, 6.7.0
.
:::moniker-end
:::moniker range=">=azure-pipelines-2022.1"
validateScriptSignature
- Validate script signature
boolean
. Optional. Use when ScriptType = FilePath
. Default value: false
.
If this is true, then the task will first check to make sure specified script is signed and valid before executing it.
:::moniker-end
All tasks have control options in addition to their task inputs. For more information, see Control options and common task properties.
:::moniker range=">=azure-pipelines-2019"
None.
:::moniker-end
Added support for Fail on standard error and ErrorActionPreference.
:::moniker range=">=azure-pipelines-2019"
Requirement | Description |
---|---|
Pipeline types | YAML, Classic build, Classic release |
Runs on | Agent, DeploymentGroup |
Demands | Self-hosted agents must have capabilities that match the following demands to run jobs that use this task: azureps |
Capabilities | This task does not satisfy any demands for subsequent tasks in the job. |
Command restrictions | Any |
Settable variables | Any |
Agent version | 2.0.0 or greater |
Task category | Deploy |
:::moniker-end