为什么我的Powershell脚本没有运行?

时间:2020-03-05 18:39:33  来源:igfitidea点击:

我写了一个简单的批处理文件作为powershell脚本,当它们运行时出现错误。

它在我的路径中的脚本目录中。

Cannot be loaded because the execution of scripts is disabled on this system. 
please see "get-help about-signing".

我看了看帮助,但没有帮助。

解决方案

回答

可能是PowerShell的默认安全级别,该默认安全级别(IIRC)仅运行签名的脚本。

尝试输入以下内容:

set-executionpolicy remotesigned

这将告诉PowerShell允许运行本地(即在本地驱动器上)未签名的脚本。

然后尝试再次执行脚本。

回答

同样值得一提的是,我们可能需要在脚本名称前添加"。"。例如:

.\scriptname.ps1