我正在尝试解决一个问题,即我无法从右键菜单运行本地 .ps1 脚本,而每次重新启动后都会出现执行策略更改警告。
重现步骤:
打开提升的 Powershell 并运行:
Set-Executionpolicy -ExecutionPolicy RemoteSigned -Scope CurrentUser
Set-Executionpolicy -ExecutionPolicy RemoteSigned -Scope Process
运行ExecutionPolicy -List
然后返回:
Scope ExecutionPolicy
----- ---------------
MachinePolicy Undefined
UserPolicy Undefined
Process RemoteSigned
CurrentUser RemoteSigned
LocalMachine RemoteSigned
但是在关闭并重新打开 Powershell 窗口并ExecutionPolicy -List
再次运行时,只有LocalMachine
设置保持不变:
Scope ExecutionPolicy
----- ---------------
MachinePolicy Undefined
UserPolicy Undefined
Process Undefined
CurrentUser Undefined
LocalMachine RemoteSigned
为什么其他的不粘?我已经运行DISM restorehealth
并且 sfc /scannow
没有收到任何错误。