c:\test\Te-6ren">
gpt4 book ai didi

powershell - 修复 PowerShell 错误 "execution of scripts is disabled on this system"的替代方法

转载 作者:行者123 更新时间:2023-12-04 14:14:18 24 4
gpt4 key购买 nike

我有一个由我编写的 PowerShell 脚本。我尝试如下运行 PowerShell 脚本;

PS C:\Documents and Settings\Administrator>c:\test\Test.ps1

所以这给了我一个错误说:

File c:\test\Test.ps1 cannot be loaded because the execution of scripts is disabled on this system. Please see "get-help about_signing" for more details.



我发现设置 Set-ExecutionPolicy Unrestricted将修复错误。

但我的问题是;
  • 此次签约是关于什么的?
  • 我们可以在不设置 Set-ExecutionPolicy Unrestricted 的情况下修复此错误吗? (做签名之类的事情)?如果是这样,该怎么做?
  • 如果我设置 Set-ExecutionPolicy Unrestricted 是否会出现安全问题在我的网络服务器中?
  • 最佳答案

    Set-ExecutionPolicy导致系统范围的变化。脚本可能存在安全漏洞,这就是默认情况下禁用所有脚本执行的原因。一种可能性是使用仅对该特定 session 有效的执行策略从命令行启动 PowerShell 进程。命令行将类似于:

    > powershell.exe -ExecutionPolicy Unrestricted -File "c:\test\Test.ps1"

    您可以通过将默认策略保留为 Restricted 并在需要时使用 RemoteSigned 或 AllSigned 策略启动 PowerShell 来将此与签名结合起来。关于 powershell.exe 命令行选项的一些附加信息是 here .

    关于powershell - 修复 PowerShell 错误 "execution of scripts is disabled on this system"的替代方法,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/17713812/

    24 4 0
    Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
    广告合作:1813099741@qq.com 6ren.com