When trying to set the execution policy for PowerShell scripts on your Windows system, you may get the following error:
Set-ExecutionPolicy : Access to the registry key
‘HKEY_LOCAL_MACHINE\SOFTWARE\ Microsoft\PowerShell\1\ShellIds\Microsoft.PowerShell’ is denied.
At line:1 char:1
This error is often displayed because you are not executing the command as an administrator. To solve this issue, try the following.
- Ensure you are logged into the computer with local administrator rights.
- Right-click or hold “Shift” and select “Windows PowerShell“ > “Run as administrator“.
- Now try to run the same set-executionpolicy command to change the execution policy. It should complete successfully.