0

有谁知道如何让我的 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
4

1 回答 1

4

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

要解决此问题,请打开Propertiesps1 文件,单击UnblockApply/OK

Unrestricted或者,如果您想允许所有内容(不推荐),您可以将执行策略设置为。

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

于 2013-11-01T10:26:07.673 回答