Running a PowerShell Script from VBS

I had a requirement for users to be able to run a PowerShell script but due to the execution policy this is disallowed.

Image

You can of course remove this restriction by running the command set-executionpolicy unrestricted but for security reasons we want it set-up so a particular script can run but no others.

The best solution we found was to use a Visual Basic Script (VBS) which calls PowerShell with the switch -executionpolicy unrestricted in the wscript.shell object.

Set objShell = CreateObject(“Wscript.shell”)

objShell.run(“powershell -executionpolicy unrestricted -file “”c:\script.ps1″””),0

 

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s