There are a number of scenarios where you might want to call PowerShell from VBScript.
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"Else 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 ArchitectVisit the Windows PowerShell Team blog at: http://blogs.msdn.com/PowerShellVisit the Windows PowerShell ScriptCenter at: http://www.microsoft.com/technet/scriptcenter/hubs/msh.mspx