Catch Powershell script errors in VBscript

Posted on 2010-01-07
Medium Priority
Last Modified: 2012-05-08
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?

Question by:jamke1
1 Comment
LVL 71

Accepted Solution

Chris Dent earned 2000 total points
ID: 26207843

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.


Featured Post

Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

A walk-through example of how to obtain and apply new DID phone numbers to your cloud PBX enabled users that are configured in Office 365. Whether you have 1, 10 or 100+ users in your tenant, it's quite easy to get them phone-enabled and making/rece…
Transferring FSMO roles is done when an admin wants to split roles between certain Domain Controllers or the Domain Controller holding the Roles has been forcefully demoted using dcpromo / forceremoval
Learn the basics of modules and packages in Python. Every Python file is a module, ending in the suffix: .py: Modules are a collection of functions and variables.: Packages are a collection of modules.: Module functions and variables are accessed us…
Loops Section Overview
Suggested Courses
Course of the Month15 days, 10 hours left to enroll

850 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question