Powershell script to trigger warning


I wrote a Powershell script to perform a task after a deployment. The task it needs to perform is not crucial and it may go wrong. I don’t want it to throw an error and impact the whole deployment, but I do want it to put the deployment in a “warning” state (yellow) - to attract attention.
I’ve experimented with Powershell exit codes and Write-Error, and saw that when the exit code is not 0 the deployment is in an “error” state. Same when I use Write-Error.
I was expecting Write-Warning to have the effect I am looking for, but the deployment is successful and green.
Perhaps there’s something I’m missing?

Thank you!


Hi Diana,

Thanks for getting in touch! Sorry about the delay in getting back to you about this.
You can use the following and it should behave how you want: Write-Error "Hello" -ErrorAction Continue

Hope that helps!

Thank you, Vanessa, that’s what I was looking for!

Similarly, Write-Warning "Hello" will put the step into a warning state which is represented by a green success icon with a warning symbol in it. I find that state to be more appropriate for cases where I expect semi-frequent failures.