Powershell甚至无法执行甚至设置执行策略

时间:2013-11-01 07:41:11

标签: windows powershell

有谁知道如何让我的ps2exe.ps1执行? 我得到了这个例外,并没有解决它的线索。

PS C:\> Set-ExecutionPolicy RemoteSigned

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 desc
about_Execution_Policies help topic. Do you want to change the execution policy?
[Y] Yes  [N] No  [S] Suspend  [?] Help (default is "Y"): Y
PS C:\> .\ps2exe.ps1
File C:\ps2exe.ps1 cannot be loaded. The file C:\ps2exe.ps1 is not digitally signed. The script will not execute on the system. Please see "get-help
At line:1 char:13
+ .\ps2exe.ps1 <<<<
    + CategoryInfo          : NotSpecified: (:) [], PSSecurityException
    + FullyQualifiedErrorId : RuntimeException

1 个答案:

答案 0 :(得分:4)

ExeutionPolicy RemoteSigned允许运行本地脚本(在您的计算机上创建)和来自其他位置的签名脚本。由于您的脚本是从Internet下载的,因此它具有与之关联的“块”属性。

要解决此问题,请为ps1文件打开Properties,然后点击UnblockApply/OK

如果您想允许所有内容(不推荐),您可以将executionpolicy设置为Unrestricted

值得一提的是,除非您已在Trusted Publishers证书库中安装了特定的发布者证书,否则签名脚本将在执行前提示确认。