当前位置:网站首页 > 更多 > 玩电脑 > 正文

[玩转系统] 运行 PowerShell 脚本时出现未数字签名错误

作者:精品下载站 日期:2024-12-14 18:06:59 浏览:15 分类:玩电脑

运行 PowerShell 脚本时出现未数字签名错误


您想要运行下载的 PowerShell 脚本,但在运行 PowerShell 脚本时收到未数字签名的错误,并且无法进一步继续。该脚本已下载到您的系统本地,并且您以管理员身份运行它。您制作的其他脚本运行良好,但无法加载下载的脚本。在本文中,您将了解为什么会首先收到此错误以及如何允许未经数字签名的 PowerShell 脚本。

没有数字签名错误

以管理员身份运行 PowerShell。将目录更改为 c:\scripts 文件夹。然后,运行您已下载的 PowerShell 脚本。你会得到一个错误。

PS C:\> cd C:\scripts

PS C:\scripts>.\script.ps1
.\script.ps1 : File C:\scripts\script.ps1 cannot be loaded. The file C:\scripts\script.ps1 is not digitally signed. You
 cannot run this script on the current system. For more information about running scripts and setting execution policy,
 see about_Execution_Policies at http://go.microsoft.com/fwlink/?LinkID=135170.
At line:1 char:1
+ .\script.ps1
+ ~~~~~~~~~~~~
    + CategoryInfo          : SecurityError: (:) [], PSSecurityException
    + FullyQualifiedErrorId : UnauthorizedAccess

如何修复未数字签名的错误?

首先,首先浏览到 Windows PowerShell 脚本文件。找到 PowerShell 脚本后,右键单击该文件,然后单击P属性

[玩转系统] 运行 PowerShell 脚本时出现未数字签名错误

留在常规选项卡上,在下面,您可以看到安全选项。它表明此文件来自另一台计算机,可能会被阻止以帮助保护此计算机。换句话说,出于安全原因您无法运行该脚本。在使用它之前,您必须信任它。

选中取消阻止框,然后单击确定

[玩转系统] 运行 PowerShell 脚本时出现未数字签名错误

现在重新运行 PowerShell 脚本。它应该按预期工作,不会出现错误。例如,无法加载脚本,并且脚本未经过数字签名。

使用 PowerShell 修复未数字签名的错误

如果要通过 PowerShell 取消阻止文件,请使用 Unblock-File cmdlet。在此示例中,我们将更改脚本文件夹的路径。之后,我们解锁脚本并启动脚本。

PS C:\>cd C:\scripts\

PS C:\scripts>Unblock-File script.ps1 ; .\script.ps1

继续阅读:Exchange 安装程序无法安装错误代码 1619 »

结论

您了解了如何修复运行 PowerShell 脚本时出现的未数字签名错误。通过文件资源管理器或 PowerShell 取消阻止文件。这是一个小修复,但很重要。您想要运行哪个 PowerShell 脚本并出现此错误?我们需要 PowerShell 脚本才能正确运行!

您喜欢这篇文章吗?您可能还喜欢 PowerShell 从文本文件中删除引号。不要忘记关注我们并分享这篇文章。

您需要 登录账户 后才能发表评论

取消回复欢迎 发表评论:

关灯