Catch Powershell script errors in VBscript

I am calling Windows Powershell 2 scripts from VBscript using Shell command.

Set Shell = CreateObject("Wscript.Shell")
Shell.Run( "powershell.exe -noexit " & <PowerShellCommand>  )  

How can I catch errors/ exceptions from Powershell script and also pass these errors back to VBscript?

Who is Participating?
Chris DentPowerShell DeveloperCommented:

VbScript has no way of accessing that information directly I'm afraid.

A couple of ways to workaround this spring to mind.

The first is using the ErrorLevel environmental variable as discussed here:

The second, is to have PowerShell log its own errors to a file. How complex that gets depends on what your script does.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.