Powershell action never raises error

I am trying Powershell action for the first time and I cannot make it raise any errors.

Steps to reproduce:

- Add “Execute PowerShell Script” action
- In the “Script” tab, in the bottom large memo labeled “Specify Script” enter anything you like, for example “asdfasdfasdf”
- Run this action
- Automise will show that action completed successfully

Automise v3 3.0.0.515, check for updates tells “no new versions available”

Alex

Hi Alex,

This is not a bug, but a ‘by design’ feature of Powershell. By default Powershell will continue running for most errors encountered in your script, you will need to set the $ErrorActionPreference to “Stop” at the top of your script for the action to fail (i.e. $ErrorActionPreference = “Stop”; )

More info: http://blogs.msdn.com/powershell/archive/2006/04/25/583241.aspx

Regards,
Paul.

Got it.

But how do I know from Automise that there was an error in PowerShell script?

I need Automise action to fail if there was any error in the PowerShell script. How do I do this?

Thank you

Alex

Hi Alex,

The action should fail when the $ErrorActionPreference variable is set to stop and an error is encountered.

Regards,
Paul.

Thank you. That worked !