我有一个 PowerShell 脚本,我想用它来自动化一些事情。我通过右键单击它并选择“使用 PowerShell 运行”来运行它。
我Set-ExecutionPolicy Bypass
在 32 位和 64 位 PowerShell 中都运行过,并使用Get-ExecutionPolicy
.
尽管如此,每次重新启动后我第一次尝试运行脚本时,都会收到以下提示:
Execution Policy Change
The execution policy helps protect you from scripts that you do not trust. Changing the execution policy might expose
you to the security risks described in the about_Execution_Policies help topic at
http://go.microsoft.com/fwlink/?LinkID=135170. Do you want to change the execution policy?
[Y] Yes [A] Yes to All [N] No [L] No to All [S] Suspend [?] Help (default is "N"):
如果我只是关闭 PowerShell 窗口并再次运行它,则没有提示。无论我输入Y
还是N
提示,脚本都会运行。
剧本中没有什么好笑的,只是echo "Test"
。同样的事情发生在三台不同的计算机上,Win 8.1、Win 10 和虚拟化 Win 10。它们都安装了 PowerShell 5.0。
我究竟做错了什么?我怎样才能摆脱这个提示?