简体   繁体   English

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

[英]Powershell cannot execute even set the execution policy

Is anyone know how to get my ps2exe.ps1 to be execute?? 有谁知道如何让我的ps2exe.ps1被执行? I got this exception and no clue to solve it. 我有这个例外,没有解决的线索。

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

The ExeutionPolicy RemoteSigned allows running of local scripts(created on your computer) and signed scripts from other locations. ExeutionPolicy RemoteSigned允许运行本地脚本(在计算机上创建)和其他位置的签名脚本。 Since your scripts is downloaded from the internet, it has a "block"-attribute associated with it. 由于您的脚本是从Internet下载的,因此具有与之相关的“阻止”属性。

To fix this, open Properties for the ps1-file, click Unblock and Apply/OK . 要解决此问题,请打开ps1-file的“ Properties ”,单击“ UnblockApply/OK

Or you could set the executionpolicy to Unrestricted if you want to allow everything(not recommended). 或者,如果您想允许所有操作,则可以将执行策略设置为“ Unrestricted (不建议)。

It may be worth mentioning that signed scripts will prompt for confirmation before execution unless you already have the specific publishers certificate installed in Trusted Publishers certificate store. 值得一提的是,除非您已经在Trusted Publishers证书存储中安装了特定的发布者证书,否则签名的脚本将在执行之前提示您进行确认。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM