How make script change status to error?

PSU 2.10.2

How can I make a script change status to Error or similar?
I get errors in my script but the status still show Success

If you set the ErrorAction option to Stop for the script it will fail the script on error.

When Iā€™m using write-warning then I get Warning as status. It would be perfect if you can use Write-Error also :slight_smile: