Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

I'm running Windows Server 2008 as admin and I tried to set ExecutionPolicy as Remotesigned for PowerShell v2 like this:

Set-ExecutionPolicy RemoteSigned

But I got this error:

Set-ExecutionPolicy : Access to the registry key 'HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\PowerShell\1\ShellIds\Microsoft
.PowerShell' is denied.
At line:1 char:20
+ Set-ExecutionPolicy <<<<  RemoteSigned
    + CategoryInfo          : NotSpecified: (:) [Set-ExecutionPolicy], UnauthorizedAccessException
    + FullyQualifiedErrorId : System.UnauthorizedAccessException,Microsoft.PowerShell.Commands.SetExecutionPolicyComma
   nd

How to fix this?

share|improve this question

4 Answers 4

up vote 17 down vote accepted

Right click on Powershell shortcut and choose 'Run as Administrator'

share|improve this answer
4  
Also note that if you have a 64-bit OS you need to set the execution policy for both the 32-bit and 64-bit version of PowerShell. –  Joey Mar 24 '10 at 16:27
    
Thanks very much! –  atricapilla Mar 24 '10 at 17:05

In case "Run as Administrator" doesn't work for you(didn't for me at first) or if you want a permanent solution, I found a fix by adding the permissions directly to the windows registry. After doing this when I called get-ExecutionPolicy it no longer came back restricted.

It's the equivalent of set-ExecutionPolicy RemoteSigned, with it actually working.

Wrote about it here: http://kyleclegg.com/powershell/

Hope this helps.

share|improve this answer

I found that the only solution to this error that worked for me was to run regedt32 & drill down to the key then change the permissions for users from read to full control. Local permissions on the server take precedent to the domain admin rights.

share|improve this answer
    
Not really a good answer, given the other two answers already present... –  HopelessN00b Nov 21 '12 at 5:43

Stephen Jennings in reply to the same question on StackOverflow:

Set-ExecutionPolicy Unrestricted -Scope CurrentUser

This will set the execution policy for the current user (stored in HKEY_CURRENT_USER) rather than the local machine (HKEY_LOCAL_MACHINE).

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.