从php错误执行IIS Service Add-New-WebSite的Powershell脚本

问题描述

我正在尝试从PHP执行IIS服务的功能强大的脚本,但是会引发错误

代码如下:

<!-- PHP code -->
<?PHP
  $pssf = "C:\inetpub\wwwroot\sam\sam.ps1";
  $op = Shell_Exec ('powershell.exe -executionpolicy bypass -noprofile -File '.$pssf);
  echo $op;
?>

<!-- Powershell script code -->
try{
  Import-Module WebAdministration
  ## Creating a simple website using the cmdlets
  New-Website -Name "sa" -PhysicalPath C:\inetpub\wwwroot\ -Port 82;
  Write-Host ("`nEntered successfull.`n`n");
}
catch {
  Write-Host "An error occurred:"
  Write-Host $_
}

我在上面提到的是我以前用来执行任务的PHP和PowerShell脚本的代码。虽然我使用此代码执行代码,但我遇到了问题。在这里我提到了屏幕截图。

enter image description here

解决方法

暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!

如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。

小编邮箱:dio#foxmail.com (将#修改为@)