ausführen eines Powershell-Skript aus php

Ich versuche zum ausführen eines powershell-Skript von PHP, aber es scheint nicht zu funktionieren.

Das Skript 'newEvent.ps1' erstellt ein Ereignis auf dem Exchange-server.

$psPath = "powershell.exe";
$psDIR = "C:\\wamp\\www\\ant\\assets\\ps\\";
$psScript = "newEvent.ps1";
$runScript = $psDIR. $psScript;
$runCMD = $psPath." ".$runScript." 2>&1"; 

echo "\$psPath  $psPath <br>";
echo "\$psDIR  $psDIR <br>";
echo "\$psScript  $psScript <br>";
echo "\$runScript  $runScript <br>";
echo "\$runCMD   $runCMD  <br>";

exec( $runCMD,$out,$ret);

echo "<pre>";
print_r($out);
print_r($ret);
echo "</pre>";

It-Ausgänge:

$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>&1

Array
(
    [0] => File C:\wamp\www\ant\assets\ps\newEvent.ps1 cannot be loaded because the execut
    [1] => ion of scripts is disabled on this system. Please see "get-help about_signing"
    [2] => for more details.
    [3] => At line:1 char:39
    [4] => + C:\wamp\www\ant\assets\ps\newEvent.ps1 <<<<
    [5] =>     + CategoryInfo          : NotSpecified: (:) [], PSSecurityException
    [6] =>     + FullyQualifiedErrorId : RuntimeException
    [7] => 
)

Wenn ich powershell.exe C:\wamp\www\ant\assets\ps\newEvent.ps1 auf der Kommandozeile, funktioniert es einwandfrei.

Dies ist das erste mal, im Versuch, so etwas wie dieses. Ich lief Set-ExecutionPolicy RemoteSigned -Scope LocalMachine aber es gibt mir immer noch den gleichen Fehler.
In der Tat lief ich Set-ExecutionPolicy unristricted, aber es ist immer noch das gleiche.

  • Blick auf die Befehlszeile, die Sie ausführen.
  • Stellen Sie sicher gehen in die 32-bit-und 64-bit-Instanzen und legen Sie die Ausführungsrichtlinie dann wiederholen. -> Set-ExecutionPolicy Unrestricted
InformationsquelleAutor heshanh | 2011-03-15
Schreibe einen Kommentar