How to Run a PowerShell script inside a VBS script

To Run a PowerShell script inside a vbs script can be usefull for many reasons, and its a quick and dirty way to run PowerShell scripts in environments where execution policy normally stops you from running your scripts. A vbs wrapper script is what I use to launch PowerShell scripts in those scenarios.

This is the vbs wrapper i use to run PowerShell scripts.

Wrapper.vbs

Set objShell = CreateObject("Wscript.shell")
objShell.run("powershell -Executionpolicy Bypass -nologo -noninteractive -file .\script.ps1 -parameter Example")

Execute: cscript Wrapper.vbs

Note: You can also use this vbs script to run other vbs scripts inside the vbs script.

Ed Wilson (Microsofts scripting guy) also have a blog post about using vbscripts to run PowerShell. https://blogs.technet.microsoft.com/heyscriptingguy/2012/07/18/how-to-use-vbscript-to-run-a-powershell-script/

Anders Rødland

Anders Rødland started his IT career in 2006. My main focus is MS Configuration Manager and client management, and I have passed 17 Microsoft certifications since then. My main expertise is on client management with Microsoft Endpoint Manager: Intune and Configuration Manager. I also do a lot of work on the security side with Microsoft Defender for Endpoint. In addition to my Microsoft certification, I also have an ITIL v3 Foundation certification. This is my private blog and do not represent my employer. I use this to share information that I find useful. Sharing is caring.

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.