Scenario / Questions
I’m running Windows Server 2008 as admin and I tried to set ExecutionPolicy as Remotesigned for PowerShell v2 like this:
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?
Find below all possible solutions or suggestions for the above questions..
Right click on Powershell shortcut and choose ‘Run as Administrator’
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).
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:
Hope this helps.
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.
Disclaimer: This has been sourced from a third party syndicated feed through internet. We are not responsibility or liability for its dependability, trustworthiness, reliability and data of the text. We reserves the sole right to alter, delete or remove (without notice) the content in its absolute discretion for any reason whatsoever.