我想执行一个脚本。不幸的是,我的系统拒绝这样做(来自提升的提示):
PS C:\Users\x\Desktop> .\Set-CustomPresence.ps1
.\Set-CustomPresence.ps1: File C:\Users\x\Desktop\Set-CustomPresence.ps1 cannot be loaded because running scripts is disabled on this system. For more information, see about_Execution_Policies at https://go.microsoft.com/fwlink/?LinkID=135170.
我按照上述建议强制Undefined
进入状态:
PS C:\Users\x\Desktop> Get-ExecutionPolicy -List
Scope ExecutionPolicy
----- ---------------
MachinePolicy Undefined
UserPolicy Undefined
Process Undefined
CurrentUser Undefined
LocalMachine Undefined
错误仍然相同,脚本拒绝启动。我该如何解决?
您需要设置限制较少的执行策略。
跑
Set-ExecutionPolicy RemoteSigned
出现提示时,选择最适合您的答案。
另一种手动启用它的简单方法
regedit
,然后单击是。HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\PowerShell\1\ShellIds\
ExecutionPolicy
然后单击“修改”RemoteSigned
然后单击保存;现在享受你的剧本?