【发布时间】:2020-10-21 19:14:16
【问题描述】:
我有一个简单的 PHP 页面,它调用一个简单的 PowerShell 脚本。
test.php
<?php
$runCMD = "powershell.exe -NoProfile -ExecutionPolicy Bypass -File teste.ps1 2>&1";
exec($runCMD,$out,$ret);
if ($ret != 0) {
echo "Could not run PowerShell.";
} else {
echo implode("\n",$out);
}
?>
test.ps1
Write-Host "Just testing!"
当两个文件都放在 c:\inetpub\wwwroot 中时,一切正常。但是,如果我将它们放在共享网络文件夹中(例如,\\myserver\test)并将 IIS 指向该文件夹,php 仍然可以工作,但它不再能够运行 PowerShell 脚本。 exec 只返回错误代码 1 并打印消息“无法运行 PowerShell”。我目前正在使用 PHP 7.4.1、IIS 10、Windows Server 2019 和 PowerShell 5.1。
关于如何解决这个问题的任何想法?
【问题讨论】:
标签: php powershell iis