{"id":17892,"date":"2008-07-25T13:18:50","date_gmt":"2008-07-25T21:18:50","guid":{"rendered":"http:\/\/devblogs.microsoft.com\/powershell\/?p=17892"},"modified":"2019-06-07T13:20:33","modified_gmt":"2019-06-07T21:20:33","slug":"invoking-powershell-from-vbscript-com","status":"publish","type":"post","link":"https:\/\/devblogs.microsoft.com\/powershell\/invoking-powershell-from-vbscript-com\/","title":{"rendered":"Invoking PowerShell from VBScript (COM)"},"content":{"rendered":"<p><P>There are a number of scenarios where you might want to call PowerShell from VBScript.&nbsp; <\/P>\n<UL>\n<LI>You might already have an VBScript that does some function and you want to update it to include some PowerShell operation but don&#8217;t want to convert the entire script to PowerShell.&nbsp; <\/LI>\n<LI>You might have some people on your staff that&nbsp;are very comfortable with&nbsp;VBScipt and aren&#8217;t ready to put it down and do everything in PowerShell.&nbsp; <\/LI>\n<LI>You might have a management tool that is hardwired to invoke VBScripts and doesn&#8217;t know anything about PowerShell (yet!).<\/LI><\/UL>\n<P>These are some of the scenarios we thought about when we considered providing a COM interface to the PowerShell engine.&nbsp; To ship is to choose and this scenario got a lower priority than other features so we never got around to it.&nbsp; Luckily, the superstars at <A class=\"\" href=\"http:\/\/www.sapien.com\/\" mce_href=\"http:\/\/www.sapien.com\/\">Sapien <\/A>have come to the rescue with <A class=\"\" href=\"http:\/\/blog.sapien.com\/index.php\/2008\/06\/25\/activexposh-is-now-a-free-download\/\" mce_href=\"http:\/\/blog.sapien.com\/index.php\/2008\/06\/25\/activexposh-is-now-a-free-download\/\">ActiveXPosh<\/A> .&nbsp;&nbsp; ActiveXPosh is a COM component which gives you easy access to PowerShell from any COM capable scripting language (VBScript, JScript and others).&nbsp;&nbsp; This has been out for a while but it came out during a period when my hair was on fire so I don&#8217;t recall seeing it.&nbsp; There is a good description of its capabilities <A class=\"\" href=\"http:\/\/support.sapien.com\/bulletins\/activexposh.pdf\" mce_href=\"http:\/\/support.sapien.com\/bulletins\/activexposh.pdf\">HERE<\/A>.<BR><BR>With ActiveXPosh you can do things like:<\/P>\n<P>Set ActiveXPosh = CreateObject(&#8220;SAPIEN.ActiveXPosh&#8221;)<BR>if ActiveXPosh.Eval(&#8220;Get-Process Winword&#8221;) = vbTrue Then<BR>&nbsp;&nbsp;&nbsp;&nbsp; WScript.Echo &#8220;Word is running&#8221;<BR>Else<BR>&nbsp;&nbsp;&nbsp;&nbsp; WScript.Echo &#8220;Word is NOT&nbsp;running&#8221;<BR>End If<\/P>\n<P>Pretty simple stuff!&nbsp; So &#8211; how could it get any better?&nbsp; Yup &#8211; you guessed it, ActiveXPosh is FREE.&nbsp; Is this a wonderful world or what?<\/P>\n<P>Thank you SAPIEN!<\/P>\n<P>Jeffrey Snover [MSFT]<BR>Windows Management Partner Architect<BR>Visit the Windows PowerShell Team blog at:&nbsp;&nbsp;&nbsp; <A href=\"http:\/\/blogs.msdn.com\/PowerShell\">http:\/\/blogs.msdn.com\/PowerShell<\/A><BR>Visit the Windows PowerShell ScriptCenter at:&nbsp; <A href=\"http:\/\/www.microsoft.com\/technet\/scriptcenter\/hubs\/msh.mspx\">http:\/\/www.microsoft.com\/technet\/scriptcenter\/hubs\/msh.mspx<\/A><BR><\/P><\/p>\n","protected":false},"excerpt":{"rendered":"<p>There are a number of scenarios where you might want to call PowerShell from VBScript.&nbsp; You might already have an VBScript that does some function and you want to update it to include some PowerShell operation but don&#8217;t want to convert the entire script to PowerShell.&nbsp; You might have some people on your staff that&nbsp;are [&hellip;]<\/p>\n","protected":false},"author":600,"featured_media":13641,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"_acf_changed":false,"footnotes":""},"categories":[1],"tags":[],"class_list":["post-17892","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-powershell"],"acf":[],"blog_post_summary":"<p>There are a number of scenarios where you might want to call PowerShell from VBScript.&nbsp; You might already have an VBScript that does some function and you want to update it to include some PowerShell operation but don&#8217;t want to convert the entire script to PowerShell.&nbsp; You might have some people on your staff that&nbsp;are [&hellip;]<\/p>\n","_links":{"self":[{"href":"https:\/\/devblogs.microsoft.com\/powershell\/wp-json\/wp\/v2\/posts\/17892","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/devblogs.microsoft.com\/powershell\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/devblogs.microsoft.com\/powershell\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/powershell\/wp-json\/wp\/v2\/users\/600"}],"replies":[{"embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/powershell\/wp-json\/wp\/v2\/comments?post=17892"}],"version-history":[{"count":0,"href":"https:\/\/devblogs.microsoft.com\/powershell\/wp-json\/wp\/v2\/posts\/17892\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/powershell\/wp-json\/wp\/v2\/media\/13641"}],"wp:attachment":[{"href":"https:\/\/devblogs.microsoft.com\/powershell\/wp-json\/wp\/v2\/media?parent=17892"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/powershell\/wp-json\/wp\/v2\/categories?post=17892"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/powershell\/wp-json\/wp\/v2\/tags?post=17892"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}