Getting a failure in a powershell job to fail the Travis CI job

#1

We are doing powershell -ExecutionPolicy RemoteSigned -File .travis.ps1 which works as expected but maybe it works too well. If there is a failure in the powershell script, that error does not get returned back to Travis. We would like the Travis job to fail if the powershell script fails but we have not found a way to make that happen.

#2

Answer: In a .ps1 fileā€¦

    $error.clear()
    try { 
	java -version
    } catch { 
	echo "java -version failed"
	exit 1
    }