PowerShell显示“此系统上禁用了脚本执行”。

86 阅读1分钟

内容来自 DOC https://q.houxu6.top/?s=PowerShell显示“此系统上禁用了脚本执行”。

你正在尝试在cmd.exe中运行一个调用PowerShell脚本的cmd文件,但是遇到了这个错误:

Management_Install.ps1无法加载,因为此系统禁止执行脚本。

你已经运行了这个命令:

Set-ExecutionPolicy -ExecutionPolicy Unrestricted

当你在PowerShell中运行Get-ExecutionPolicy时,它返回Unrestricted

Get-ExecutionPolicy

输出:

Unrestricted

问题出在你尝试在64位的PowerShell中运行32位的脚本。你需要在32位的PowerShell中运行这个脚本。请按照以下步骤操作:

  1. 打开“开始”菜单,搜索“Windows PowerShell”,然后右键点击“Windows PowerShell”,选择“以管理员身份运行”。
  2. 在32位的PowerShell窗口中,重新运行以下命令:
Set-ExecutionPolicy -ExecutionPolicy Unrestricted
  1. 现在再次尝试运行你的脚本:
cd "C:\Projects\Microsoft.Practices.ESB\Source\Samples\Management Portal\Install\Scripts"
powershell .\Management\_Install.ps1 1