At the time I didn't have the capability to sign the script but I didn't want to complicate things for the user by asking them to run an elevated prompt and re-configure PowerShell's execution policy for remote-signed code. I looked around for a workaround and this is what I found.
First, the guys at Wintellect developed a simple workaround for elevation in the command shell for Vista or Windows 7. Get a copy here: http://www.wintellect.com/cs/blogs/jrobbins/archive/2007/03/27/elevate-a-process-at-the-command-line-in-vista.aspx
Next, powershell has a command line option to bypass the execution policy.
Combining the two together in a batch file delivers a simple way to accomplish my objective:
elevate powershell.exe -nologo -noprofile -windowstyle hidden -command "& {set-executionpolicy Bypass -scope Process; .\myscript.ps1}"
No comments:
Post a Comment