I'm running PS scripts from VBScript and would like to throw exception in VBScript if there were errors in PS. This is the VBScript code I use to run PowerShell:
Option Explicit
Dim oShell, appCmd
Set oShell = CreateObject("WScript.Shell")
appCmd = "powershell set-executionpolicy unrestricted -force; c:\3.ps1"
oShell.Run appCmd, 4, true
This is my PS script:
throw "I'm exception"
I've tried general VBScript catch:
if( Err.number <> 0 ) then
Err.raise()
end if
but it doesn't seem to work. I would love to use only PS and get rid of VBScript altogether, but it's another application that is running VBs and it only supports VBs. Any ideas?
I could write exception in file in PS and then from VBs check if file exist and throw exception, but I hope there's a better way. Thanks