Indicate failure from powershell script?

I understand that you can use a powershell script for predeploy, deploy, and postdeploy octopus deployment customization. If we need to fail the deploy due to something bad happening in the powershell script, how do indicate failure from script so that the octopus deploy will show failure as well?

thanks

If you return a non-zero exit code Octopus will treat it as a failure. There’s a little more information in this blog post.