【发布时间】:2011-05-01 13:51:37
【问题描述】:
我正在尝试运行一个从 cmd.exe 调用 PowerShell 脚本的 cmd 文件,但我收到此错误:
Management_Install.ps1无法加载,因为此系统上禁用了脚本的执行。
我运行了这个命令:
Set-ExecutionPolicy -ExecutionPolicy Unrestricted
当我从 PowerShell 运行 Get-ExecutionPolicy 时,它返回 Unrestricted。
PS C:\Users\Administrator\> Get-ExecutionPolicy
Unrestricted
C:\Projects\Microsoft.Practices.ESB\Source\Samples\Management Portal\Install\Scripts> powershell .\Management_Install.ps1 1
警告:正在运行 x86 PowerShell...
无法加载文件
C:\Projects\Microsoft.Practices.ESB\Source\Samples\Management Portal\Install\Scripts\Management_Install.ps1,因为此系统上禁用了脚本执行。详情请见“get-help about_signing”。在 line:1 char:25
.\Management_Install.ps1
CategoryInfo : NotSpecified: (:) [], PSSecurityException
FullyQualifiedErrorId : RuntimeException
C:\Projects\Microsoft.Practices.ESB\Source\Samples\Management Portal\Install\Scripts> 暂停
按任意键继续。 . .
系统是Windows Server 2008R2。
我做错了什么?
【问题讨论】:
-
值得指出的是,Execution Policy 具有多个作用域,以不同的方式运行 PowerShell 可以获得不同的策略。要查看策略列表,请运行
Get-ExecutionPolicy -List。
标签: powershell windows-server-2008-r2