Note that there are some explanatory texts on larger screens.

plurals
  1. POexecuting a Powershell script from php
    primarykey
    data
    text
    <p>I'm trying to execute a powershell script from PHP, but it does not seem to work.</p> <p>The script 'newEvent.ps1' creates an event on the Exchange server.</p> <pre><code>$psPath = "powershell.exe"; $psDIR = "C:\\wamp\\www\\ant\\assets\\ps\\"; $psScript = "newEvent.ps1"; $runScript = $psDIR. $psScript; $runCMD = $psPath." ".$runScript." 2&gt;&amp;1"; echo "\$psPath $psPath &lt;br&gt;"; echo "\$psDIR $psDIR &lt;br&gt;"; echo "\$psScript $psScript &lt;br&gt;"; echo "\$runScript $runScript &lt;br&gt;"; echo "\$runCMD $runCMD &lt;br&gt;"; exec( $runCMD,$out,$ret); echo "&lt;pre&gt;"; print_r($out); print_r($ret); echo "&lt;/pre&gt;"; </code></pre> <p>It outputs:</p> <pre><code>$psPath powershell.exe $psDIR C:\wamp\www\ant\assets\ps\ $psScript newEvent.ps1 $runScript C:\wamp\www\ant\assets\ps\newEvent.ps1 $runCMD powershell.exe C:\wamp\www\ant\assets\ps\newEvent.ps1 2&gt;&amp;1 Array ( [0] =&gt; File C:\wamp\www\ant\assets\ps\newEvent.ps1 cannot be loaded because the execut [1] =&gt; ion of scripts is disabled on this system. Please see "get-help about_signing" [2] =&gt; for more details. [3] =&gt; At line:1 char:39 [4] =&gt; + C:\wamp\www\ant\assets\ps\newEvent.ps1 &lt;&lt;&lt;&lt; [5] =&gt; + CategoryInfo : NotSpecified: (:) [], PSSecurityException [6] =&gt; + FullyQualifiedErrorId : RuntimeException [7] =&gt; ) </code></pre> <p>If I run <code>powershell.exe C:\wamp\www\ant\assets\ps\newEvent.ps1</code> on the command-line, it works fine.</p> <p>This is the first time im attempting something like this. I ran <code>Set-ExecutionPolicy RemoteSigned -Scope LocalMachine</code> but it still gives me the same error. In fact I ran <code>Set-ExecutionPolicy unristricted</code>, but it's still the same.</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload