steps.powershell definition
The powershell step runs a script in Windows PowerShell.
steps:
- powershell: string # Required as first property. Inline PowerShell or reference to a PowerShell file.
errorActionPreference: string # Unless otherwise specified, the error action preference defaults to the value stop. See the following section for more information..
failOnStderr: string # Fail the task if output is sent to Stderr?.
ignoreLASTEXITCODE: string # Check the final exit code of the script to determine whether the step succeeded?.
workingDirectory: string # Start the script with this working directory.
condition: string # Evaluate this condition expression to determine whether to run this task.
continueOnError: boolean # Continue running even on failure?. (false,n,no,off,on,true,y,yes)
displayName: string # Human-readable name for the task.
enabled: boolean # Run this task when the job runs?. (false,n,no,off,on,true,y,yes)
env: # Variables to map into the process's environment
string: string # Name/value pairs.
name: string # ID of the step. ([-_A-Za-z0-9]*)
timeoutInMinutes: string # Time to wait for this task to complete before the server kills it.
Properties that use this definition: steps
Properties
powershell
string
Required as first parameter. Inline PowerShell or reference to a PowerShell file.errorActionPreference
string
Unless otherwise specified, the error action preference defaults to the value stop. See the following section for more information.failOnStderr
string
Fail the task if output is sent to Stderr?ignoreLASTEXITCODE
string
Check the final exit code of the script to determine whether the step succeeded?workingDirectory
string
Start the script with this working directory.condition
string
Evaluate this condition expression to determine whether to run this task.continueOnError
boolean
Continue running even on failure?displayName
string
Human-readable name for the task.enabled
boolean
Run this task when the job runs?env
string name/value pairs
Variables to map into the process's environment.name
string
ID of the step. Acceptable values: [_A-Za-z0-9]*timeoutInMinutes
string
Time to wait for this task to complete before the server kills it.steps:
- powershell: string # Required as first property. Inline PowerShell or reference to a PowerShell file.
errorActionPreference: string # Unless otherwise specified, the error action preference defaults to the value stop. See the following section for more information..
failOnStderr: string # Fail the task if output is sent to Stderr?.
ignoreLASTEXITCODE: string # Check the final exit code of the script to determine whether the step succeeded?.
workingDirectory: string # Start the script with this working directory.
condition: string # Evaluate this condition expression to determine whether to run this task.
continueOnError: boolean # Continue running even on failure?. (false,n,no,off,on,true,y,yes)
displayName: string # Human-readable name for the task.
enabled: boolean # Run this task when the job runs?. (false,n,no,off,on,true,y,yes)
env: # Variables to map into the process's environment
string: string # Name/value pairs.
name: string # ID of the step. ([-_A-Za-z0-9]*)
timeoutInMinutes: string # Time to wait for this task to complete before the server kills it.
Properties that use this definition: steps
Properties
powershell
string
Required as first parameter. Inline PowerShell or reference to a PowerShell file.errorActionPreference
string
Unless otherwise specified, the error action preference defaults to the value stop. See the following section for more information.failOnStderr
string
Fail the task if output is sent to Stderr?ignoreLASTEXITCODE
string
Check the final exit code of the script to determine whether the step succeeded?workingDirectory
string
Start the script with this working directory.condition
string
Evaluate this condition expression to determine whether to run this task.continueOnError
boolean
Continue running even on failure?displayName
string
Human-readable name for the task.enabled
boolean
Run this task when the job runs?env
string name/value pairs
Variables to map into the process's environment.name
string
ID of the step. Acceptable values: [_A-Za-z0-9]*timeoutInMinutes
string
Time to wait for this task to complete before the server kills it.steps:
- powershell: string # Required as first property. Inline PowerShell or reference to a PowerShell file.
errorActionPreference: string # Unless otherwise specified, the error action preference defaults to the value stop. See the following section for more information..
failOnStderr: string # Fail the task if output is sent to Stderr?.
ignoreLASTEXITCODE: string # Check the final exit code of the script to determine whether the step succeeded?.
workingDirectory: string # Start the script with this working directory.
condition: string # Evaluate this condition expression to determine whether to run this task.
continueOnError: boolean # Continue running even on failure?. (false,n,no,off,on,true,y,yes)
displayName: string # Human-readable name for the task.
target: stepTarget # Environment in which to run this task
enabled: boolean # Run this task when the job runs?. (false,n,no,off,on,true,y,yes)
env: # Variables to map into the process's environment
string: string # Name/value pairs.
name: string # ID of the step. ([-_A-Za-z0-9]*)
timeoutInMinutes: string # Time to wait for this task to complete before the server kills it.
Properties that use this definition: steps
Properties
powershell
string
Required as first parameter. Inline PowerShell or reference to a PowerShell file.errorActionPreference
string
Unless otherwise specified, the error action preference defaults to the value stop. See the following section for more information.failOnStderr
string
Fail the task if output is sent to Stderr?ignoreLASTEXITCODE
string
Check the final exit code of the script to determine whether the step succeeded?workingDirectory
string
Start the script with this working directory.condition
string
Evaluate this condition expression to determine whether to run this task.continueOnError
boolean
Continue running even on failure?displayName
string
Human-readable name for the task.target
enabled
boolean
Run this task when the job runs?env
string name/value pairs
Variables to map into the process's environment.name
string
ID of the step. Acceptable values: [_A-Za-z0-9]*timeoutInMinutes
string
Time to wait for this task to complete before the server kills it.steps:
- powershell: string # Required as first property. Inline PowerShell or reference to a PowerShell file.
errorActionPreference: string # Unless otherwise specified, the error action preference defaults to the value stop. See the following section for more information..
failOnStderr: string # Fail the task if output is sent to Stderr?.
ignoreLASTEXITCODE: string # Check the final exit code of the script to determine whether the step succeeded?.
workingDirectory: string # Start the script with this working directory.
condition: string # Evaluate this condition expression to determine whether to run this task.
continueOnError: boolean # Continue running even on failure?. (false,n,no,off,on,true,y,yes)
displayName: string # Human-readable name for the task.
target: stepTarget # Environment in which to run this task
enabled: boolean # Run this task when the job runs?. (false,n,no,off,on,true,y,yes)
env: # Variables to map into the process's environment
string: string # Name/value pairs.
name: string # ID of the step. ([-_A-Za-z0-9]*)
timeoutInMinutes: string # Time to wait for this task to complete before the server kills it.
Properties that use this definition: steps
Properties
powershell
string
Required as first parameter. Inline PowerShell or reference to a PowerShell file.errorActionPreference
string
Unless otherwise specified, the error action preference defaults to the value stop. See the following section for more information.failOnStderr
string
Fail the task if output is sent to Stderr?ignoreLASTEXITCODE
string
Check the final exit code of the script to determine whether the step succeeded?workingDirectory
string
Start the script with this working directory.condition
string
Evaluate this condition expression to determine whether to run this task.continueOnError
boolean
Continue running even on failure?displayName
string
Human-readable name for the task.target
enabled
boolean
Run this task when the job runs?env
string name/value pairs
Variables to map into the process's environment.name
string
ID of the step. Acceptable values: [_A-Za-z0-9]*timeoutInMinutes
string
Time to wait for this task to complete before the server kills it.steps:
- powershell: string # Required as first property. Inline PowerShell or reference to a PowerShell file.
errorActionPreference: string # Unless otherwise specified, the error action preference defaults to the value stop. See the following section for more information..
failOnStderr: string # Fail the task if output is sent to Stderr?.
ignoreLASTEXITCODE: string # Check the final exit code of the script to determine whether the step succeeded?.
workingDirectory: string # Start the script with this working directory.
condition: string # Evaluate this condition expression to determine whether to run this task.
continueOnError: boolean # Continue running even on failure?. (false,n,no,off,on,true,y,yes)
displayName: string # Human-readable name for the task.
target: stepTarget # Environment in which to run this task
enabled: boolean # Run this task when the job runs?. (false,n,no,off,on,true,y,yes)
env: # Variables to map into the process's environment
string: string # Name/value pairs.
name: string # ID of the step. ([-_A-Za-z0-9]*)
timeoutInMinutes: string # Time to wait for this task to complete before the server kills it.
retryCountOnTaskFailure: string # Number of retries if the task fails.
Properties that use this definition: steps
Properties
powershell
string
Required as first parameter. Inline PowerShell or reference to a PowerShell file.errorActionPreference
string
Unless otherwise specified, the error action preference defaults to the value stop. See the following section for more information.failOnStderr
string
Fail the task if output is sent to Stderr?ignoreLASTEXITCODE
string
Check the final exit code of the script to determine whether the step succeeded?workingDirectory
string
Start the script with this working directory.condition
string
Evaluate this condition expression to determine whether to run this task.continueOnError
boolean
Continue running even on failure?displayName
string
Human-readable name for the task.target
enabled
boolean
Run this task when the job runs?env
string name/value pairs
Variables to map into the process's environment.name
string
ID of the step. Acceptable values: [-_A-Za-z0-9]*timeoutInMinutes
string
Time to wait for this task to complete before the server kills it.retryCountOnTaskFailure
string
Number of retries if the task fails.steps:
- powershell: string # Required as first property. Inline PowerShell or reference to a PowerShell file.
errorActionPreference: string # Unless otherwise specified, the error action preference defaults to the value stop. See the following section for more information..
failOnStderr: string # Fail the task if output is sent to Stderr?.
ignoreLASTEXITCODE: string # Check the final exit code of the script to determine whether the step succeeded?.
workingDirectory: string # Start the script with this working directory.
condition: string # Evaluate this condition expression to determine whether to run this task.
continueOnError: boolean # Continue running even on failure?. (false,n,no,off,on,true,y,yes)
displayName: string # Human-readable name for the task.
target: stepTarget # Environment in which to run this task
enabled: boolean # Run this task when the job runs?. (false,n,no,off,on,true,y,yes)
env: # Variables to map into the process's environment
string: string # Name/value pairs.
name: string # ID of the step. ([-_A-Za-z0-9]*)
timeoutInMinutes: string # Time to wait for this task to complete before the server kills it.
retryCountOnTaskFailure: string # Number of retries if the task fails.
Properties that use this definition: steps
Properties
powershell
string
Required as first parameter. Inline PowerShell or reference to a PowerShell file.errorActionPreference
string
Unless otherwise specified, the error action preference defaults to the value stop. See the following section for more information.failOnStderr
string
Fail the task if output is sent to Stderr?ignoreLASTEXITCODE
string
Check the final exit code of the script to determine whether the step succeeded?workingDirectory
string
Start the script with this working directory.condition
string
Evaluate this condition expression to determine whether to run this task.continueOnError
boolean
Continue running even on failure?displayName
string
Human-readable name for the task.target
enabled
boolean
Run this task when the job runs?env
string name/value pairs
Variables to map into the process's environment.name
string
ID of the step. Acceptable values: [-_A-Za-z0-9]*timeoutInMinutes
string
Time to wait for this task to complete before the server kills it.retryCountOnTaskFailure
string
Number of retries if the task fails.Remarks
The powershell keyword is a shortcut for the PowerShell task.
The task runs a script in Windows PowerShell.
Each PowerShell session lasts only for the duration of the job in which it runs. Tasks that depend on what has been bootstrapped must be in the same job as the bootstrap.
Learn more about conditions and timeouts.
Error action preference
Unless otherwise specified, the error action preference defaults to the value stop, and the line $ErrorActionPreference = 'stop' is prepended to the top of your script.
When the error action preference is set to stop, errors cause PowerShell to terminate the task and return a nonzero exit code. The task is also marked as Failed.
errorActionPreference: stop | continue | silentlyContinue
steps:
- powershell: |
Write-Error 'Uh oh, an error occurred'
Write-Host 'Trying again...'
displayName: Error action preference
errorActionPreference: continue
Ignore last exit code
The last exit code returned from your script is checked by default. A nonzero code indicates a step failure, in which case the system appends your script with:
if ((Test-Path -LiteralPath variable:\LASTEXITCODE)) { exit $LASTEXITCODE }
If you don't want this behavior, specify ignoreLASTEXITCODE: true.
ignoreLASTEXITCODE: boolean
steps:
- powershell: git nosuchcommand
displayName: Ignore last exit code
ignoreLASTEXITCODE: true
Learn more about conditions and timeouts.
Examples
steps:
- powershell: Write-Host Hello $(name)
displayName: Say hello
name: firstStep
workingDirectory: $(build.sourcesDirectory)
failOnStderr: true
env:
name: Microsoft
See also
- PowerShell task
- Learn more about conditions and timeouts
Feedback
Submit and view feedback for