title: Calling PowerShell from PHP using IIS on network shared folders
body: <p>I have a simple PHP page that calls a simple PowerShell script.</p>
  <p>test.php</p>
  <pre><code>&lt;?php
      $runCMD = &quot;powershell.exe -NoProfile -ExecutionPolicy Bypass -File teste.ps1 2&gt;&amp;1&quot;;
      exec($runCMD,$out,$ret);
      if ($ret != 0) {
          echo &quot;Could not run PowerShell.&quot;;
      } else {
          echo implode(&quot;\n&quot;,$out);
      }
  ?&gt;
  </code></pre>
  <p>test.ps1</p>
  <pre><code>Write-Host &quot;Just testing!&quot;
  </code></pre>
  <p>When both files are placed in c:\inetpub\wwwroot, everything works fine. However, if I place them in a shared network folder (\\myserver\test, for example) and point IIS to this folder, php still works but it's not able to run the PowerShell script anymore. exec just returns error code 1 and the message &quot;Could not run PowerShell&quot; is printed. I am currently using PHP 7.4.1, IIS 10, Windows Server 2019 and PowerShell 5.1.</p>
  <p>Any ideas on how to solve this?</p>