13

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?

2
  • I am not able to reproduce this. It works as intended on my machine. Are you getting any errors?
    – briantist
    Jun 4, 2015 at 16:54
  • @briantist It's a Windows 10 bug.
    – Camron B
    Jun 4, 2015 at 17:35

6 Answers 6

12

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
5

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.

1
  • The only one that helped. Do you know why Set-ExecutionPolicy doesn't work?
    – nZeus
    Mar 23, 2020 at 16:20
3

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.

1

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:

enter image description here

In case you want to know the Version of Windows 10 I have: 10.0.10074

2
  • 3
    I see the unexpected behavior described by OP. Windows 10 Enterprise build 10130.
    – jscott
    Jun 5, 2015 at 1:08
  • If that is the case then you should submit the bug through Connect or see if it has already.
    – user47078
    Jun 5, 2015 at 2:17
0

You must run powershell with elevated mode before change execution policy

1
0

I found that the Registry Key located at

HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\PowerShell\1\ShellIds\Microsoft.PowerShell 

was set to RemoteSigned. Setting the value to Unrestricted has worked for me.

1
  • And this is the same as in first answer, isn't it? Oct 22, 2020 at 18:55

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .