Cannot set Powershell ExecutionPolicy for CurrentUser
Here is a sample of the commands I am running:
PS C:\> Get-ExecutionPolicy -List
Scope ExecutionPolicy
----- ---------------
MachinePolicy Undefined
UserPolicy Undefined
Process Undefined
CurrentUser Undefined
LocalMachine Unrestricted
PS C:\> Set-ExecutionPolicy Unrestricted -Scope CurrentUser
PS C:\> Get-ExecutionPolicy -List
Scope ExecutionPolicy
----- ---------------
MachinePolicy Undefined
UserPolicy Undefined
Process Undefined
CurrentUser Undefined
LocalMachine Unrestricted
I want to set the CurrentUser
to Unrestricted
, but I can't seem to do so. I checked for group policies in place as outlined in this MSDN document, but didn't find anything that was configured.
Any clue as to how I can set this?
Like all the others have said this seems to be a bug in preview build of Windows 10. I got it to work by simply providing the -Force parameter.
Setting for Local Machine:
Set-ExecutionPolicy RemoteSigned -Force
Setting for Current User:
Set-ExecutionPolicy RemoteSigned -Scope CurrentUser -Force
This seems to be a bug in Windows 10. I had to create the key HKEY_CURRENT_USER\SOFTWARE\Microsoft\PowerShell\1\ShellIds\Microsoft.PowerShell
and create a string value in that key called ExecutionPolicy
with the data Unrestricted
before it would work. Even then, I can't seem to change it without modifying the registry.
I had a more generalized powershell policy issue than the OP had, but a combination of answers found here and elsewhere ended up being needed for my Win10 Anniversary Edition to correctly update its policies:
1) Make sure this registry entry exists and is set to the lowest security level that you want to allow: HKEY_CURRENT_USER\SOFTWARE\Microsoft\PowerShell\1\ShellIds\Microsoft.PowerShell
Name:ExecutionPolicy
Type: REG_SZ
Data:Unrestricted
2) Make sure this registry entry exists and is set to the lowest security level you want to allow: HKLM:\Software\Policies\Microsoft\Windows\PowerShell
Name:ExecutionPolicy
Type: REG_SZ
Data: Unrestricted
3) Update your Group Policy by running gpedit.msc
and navigate to Computer Configuration > Administrative Templates > Windows Components > Windows PowerShell
Select Turn on Script Execution
, then Edit policy setting
with Enabled
and in the box below it that says Execution Policy
, set it to Allow All Scripts
After you've done all that, you can use ddcruver's answer by force-updating your policies depending on what you want. If you set your policies to Unrestricted, I would advise setting all the settings that populate from Get-ExecutionPolicy -List
to something more restrictive, like RemoteSigned
, as malicious powershell scripts are one of the leading causes of memory-based Windows malware.
I do not see the bug in my installation of Windows 10. I simply went through the installation using VMWare Workstation 11 and built out a VM. I ran the following without making any changes prior to it:
In case you want to know the Version of Windows 10 I have: 10.0.10074