下面是我正在运行的命令的示例:
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我想将CurrentUser设置为Unrestricted,但我似乎做不到。我检查了此MSDN文档中列出的组策略,但是没有找到配置的任何内容。
有什么线索知道我该怎么设置这个吗?
发布于 2015-06-04 17:35:38
在Windows10中,这似乎是一个错误。我必须创建键HKEY_CURRENT_USER\SOFTWARE\Microsoft\PowerShell\1\ShellIds\Microsoft.PowerShell,并在该键中创建一个名为ExecutionPolicy的字符串值,然后数据Unrestricted才能正常工作。即使如此,我似乎也不能在不修改注册表的情况下更改它。
发布于 2015-06-10 01:45:18
就像其他人说的那样,这似乎是Windows 10预览构建中的一个bug,我只是通过提供-Force参数来实现的。
本地机器的
Set-ExecutionPolicy RemoteSigned -Force当前用户的
Set-ExecutionPolicy RemoteSigned -Scope CurrentUser -Force发布于 2017-04-07 20:23:12
我有一个比OP更广义的powershell策略问题,但是在这里和其他地方找到的答案组合在一起,最终需要我的Win10周年版才能正确更新其策略:
1)确保此注册表项存在并设置为您希望允许的最低安全级别:HKEY_CURRENT_USER\SOFTWARE\Microsoft\PowerShell\1\ShellIds\Microsoft.PowerShell
Name:ExecutionPolicyType: REG_SZData:Unrestricted
2)确保此注册表项存在并设置为您希望允许的最低安全级别:HKLM:\Software\Policies\Microsoft\Windows\PowerShell
Name:ExecutionPolicyType: REG_SZData: Unrestricted
3)通过运行gpedit.msc更新组策略并导航到Computer Configuration > Administrative Templates > Windows Components > Windows PowerShell
选择Turn on Script Execution,然后编辑带有Enabled的policy setting,并在下面的框中显示Execution Policy,将其设置为Allow All Scripts
在完成所有这些之后,您可以强制使用ddcruver的答案--根据需要更新您的策略。如果您将策略设置为无限制,我建议将从Get-ExecutionPolicy -List填充的所有设置设置为更具限制性的设置,比如RemoteSigned,因为恶意powershell脚本是基于内存的Windows恶意软件的主要原因之一。
https://serverfault.com/questions/696689
复制相似问题