解决Powershell阻止脚本运行遇到的问题 Solution to powershell disable runing scripts

当使用命令 set-executionpolicy remotesigned 解除Powershell对脚本运行的限制时,目前的用户可能没有被应用新的策略。

When using the command set-executionpolicy remotesigned to allow scripts running on powershell, current user may not be appled the change.

1
2
3
4
5
6
set-executionpolicy : Windows PowerShell 已成功更新你的执行策略,但在更具体的作业域中定义的策略覆盖了该设置。由于发生覆盖,你的外壳程序将保留其当前的有效执行策略 Restricted。请键入“Get-ExecutionPolicy -List”以查看你的执行策略设置。有关详细信息,请参阅“Get-Help Set-ExecutionPolicy”。
所在位置 行:1 字符: 1
+ set-executionpolicy remotesigned
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : PermissionDenied: (:) [Set-ExecutionPolicy], SecurityException
+ FullyQualifiedErrorId : ExecutionPolicyOverride,Microsoft.PowerShell.Commands.SetExecutionPolicyCommand

这时可以使用命令Set-ExecutionPolicy RemoteSigned -Scope CurrentUser来更新当前用户的策略,然后就可以轻松地在powershell运行脚本啦~

In this case, we can use command Set-ExecutionPolicy RemoteSigned -Scope CurrentUser to update the policy on current user. It will work now.

解决Powershell阻止脚本运行遇到的问题 Solution to powershell disable runing scripts

https://smallsquare.github.io/Powershell-disable-runing-scripts/

Author

SmallSquare

Posted on

2022-03-27

Updated on

2023-03-17

Licensed under

Comments