set-executionpolicy unrestricted is denied.

Sunday, February 3rd, 2013

One of the steps we have for setting up a new LSF server is to run a powershell script which does a survey of the machine. The first step is to un-restrict the execution policy via this command:

set-executionpolicy unrestricted

The command was entered and it returned this nice little error:

Execution Policy Change
The execution policy helps protect you from scripts that you do not 
trust. Changing the execution policy might expose you to the security 
risks described in the about_Execution_Policies help topic. Do you 
want to change the execution policy?

[Y] Yes  [N] No  [S] Suspend  [?] Help (default is "Y"): y
Set-ExecutionPolicy : Access to the registry key 'HKEY_LOCAL_MACHINE\
SOFTWARE\Microsoft\PowerShell\1\ShellIds\Microsoft .PowerShell' is 

At line:1 char:20
+ set-executionpolicy <<<<  unrestricted
    + CategoryInfo          : NotSpecified: (:) [Set-ExecutionPolicy], 
    + FullyQualifiedErrorId : System.UnauthorizedAccessException,

Rather odd since all security was correct.

Two obvious ideas are to upgrade powershell or reinstall it. Neither was an option is this situation.

I did a quick look around Microsoft and found this.

I decided to try the registry option and added the login.

* Run: regedt32
* Right-Click > Permissions
* Select, and add your account, grant it “Full Control” privileges
I re-entered the set-executionpolicy command and this time it worked.



Leave a Reply

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

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

Facebook photo

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

Connecting to %s

%d bloggers like this: