Invoking PowerShell from VBScript (COM)

PowerShell Team

There are a number of scenarios where you might want to call PowerShell from VBScript. 

  • You might already have an VBScript that does some function and you want to update it to include some PowerShell operation but don’t want to convert the entire script to PowerShell. 
  • You might have some people on your staff that are very comfortable with VBScipt and aren’t ready to put it down and do everything in PowerShell. 
  • You might have a management tool that is hardwired to invoke VBScripts and doesn’t know anything about PowerShell (yet!).

These are some of the scenarios we thought about when we considered providing a COM interface to the PowerShell engine.  To ship is to choose and this scenario got a lower priority than other features so we never got around to it.  Luckily, the superstars at Sapien have come to the rescue with ActiveXPosh .   ActiveXPosh is a COM component which gives you easy access to PowerShell from any COM capable scripting language (VBScript, JScript and others).   This has been out for a while but it came out during a period when my hair was on fire so I don’t recall seeing it.  There is a good description of its capabilities HERE.

With ActiveXPosh you can do things like:

Set ActiveXPosh = CreateObject(“SAPIEN.ActiveXPosh”)
if ActiveXPosh.Eval(“Get-Process Winword”) = vbTrue Then
     WScript.Echo “Word is running”
     WScript.Echo “Word is NOT running”
End If

Pretty simple stuff!  So – how could it get any better?  Yup – you guessed it, ActiveXPosh is FREE.  Is this a wonderful world or what?

Thank you SAPIEN!

Jeffrey Snover [MSFT]
Windows Management Partner Architect
Visit the Windows PowerShell Team blog at:
Visit the Windows PowerShell ScriptCenter at:


Discussion is closed.

Feedback usabilla icon