PowerShell on Target Machines task: Non-zero exit code is marked as "pass"
See original GitHub issueInvoking a PowerShell script that exits with a non-zero code does not mark the task as failed.
E.g., simply running a .ps1 with
Exit 1
has the following output reported in the logs
Deployment status for machine '<hostname>:5985' : 'Passed'
The regular PowerShell task with an inline script marks the task as failed as expected.
Issue Analytics
- State:
- Created 6 years ago
- Reactions:8
- Comments:7 (4 by maintainers)
Top Results From Across the Web
Why does my VSTS custom task passes with exit code 1?
My custom VSTS build task won't fail. It always passes, while the $LASTEXITCODE is other then zero. The code does as expected.
Read more >PowerShell on target machines v3 task - Microsoft Learn
Use this task to execute PowerShell scripts on remote machine(s). This version of the task uses PSSession and Invoke-Command for remoting.
Read more >Powershell on target machines does not exit successfully
I have a task with a powershell script that runs on 2 machines. It looks like the following, it imports a module and...
Read more >Non-Zero return code: Ansible fails due to non-zero value
Ansible will fail if the exit status of a task is any non-zero value. Here's how we can resolve Non-Zero return code: Ansible....
Read more >Command Step | Buildkite Documentation
soft_fail, Allow specified non-zero exit statuses not to fail the build. ... Jobs that time out with an exit status of 0 are...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
@psutharsan: Not a very clean work around, but since the default $ErrorActionPreference is set to “Stop”, writing to the Error stream in your script via
Write-Error
will be terminal and result in the task being marked as failed.@pavanadepu2: I’m curious why the design is such?
Thank you for your feedback. This should be fixed now. The latest version supports additional error handling options as well.