0

我正在尝试通过 php 运行 powershell 脚本。

system("C:\\Windows\\System32\\WindowsPowerShell\\v1.0\\powershell.exe -InputFormat none -File AD_Account_Automation.ps1);

当我运行 php 脚本时,它会在 Web 浏览器中返回以下错误:

File C:\inetpub\wwwroot\Test_Automation.ps1 can not be loaded. The file C:\inetpub\wwwroot\Test_Automation.ps1 is not digitally signed. The script will not execute on the sys tem. Please see "get-help about_signing" for more details.. + CategoryInfo : NotSpecified: (:) [], ParentContainsErrorRecordE xception + FullyQualifiedErrorId : RuntimeException

我已将 PowerShell 执行策略设置为 Unrestricted 和 RemoteSigned,但它并没有解决问题。如果我从 PowerShell 命令行调用它并且如果我从 Windows 中的命令提示符调用它,该脚本运行良好。

我也尝试过以下方法:

exec("C:\\Windows\\System32\\WindowsPowerShell\\v1.0\\powershell.exe -ExecutionPolicy RemoteSigned -File C:\\inetpub\\wwwroot\\AD_Account_Automation.ps1 < NUL");

而 IIS 只是挂起。有任何想法吗?

4

1 回答 1

0

几乎可以肯定,您的托管环境不允许这样做。ActiveDirectory GroupPolicy 覆盖数字签名。哇。是的,我知道,这很糟糕,但这是有充分理由的。请联系您的托管服务提供商以检查这是否是根本原因。

编辑:实际上,根本原因要简单得多。您没有用结束引号“关闭字符串。那肯定会挂起 IIS。

于 2012-08-19T03:38:16.973 回答