Quantcast
Channel: Windows PowerShell Forum
Viewing all articles
Browse latest Browse all 2314

PowerShell Script via Batch ausführen

$
0
0

Hallo,

ich möchte ein PowerShell Script auf einem Windows XP Rechner als geplanten Task ausführen und muss deshalb zwangsweise das PS-Script über ein Batch-Script starten. Dieses Script soll in der Exchange Konsole eines Servers arbeiten. Das Script an sich funktioniert einwandfrei, jedoch die Ausführung aus der Batch nicht.

Zur Zeit verwende ich dieses Batch Script:

PowerShell.exe -PSConsoleFile "DATEI\PFAD\EXCHANGESCRIPT1.psc1" #Script soll Exchange Konsole aufrufen, funktioniert einwandfrei
SET ThisScriptsDirectory=%DATEI\PFAD
SET PowerShellScriptPath=%ThisScriptsDirectory%SCRIPT1.ps1
PowerShell -NoProfile -ExecutionPolicy Bypass -Command "& {Start-Process PowerShell -ArgumentList '-NoProfile -ExecutionPolicy Bypass -File ""%PowerShellScriptPath%""' -Verb RunAs} SCRIPT1.ps1";

Die Exchange Konsole wird angesprochen, in der CMD Shell wird PowerShell gestartet, allerdings führt er dann das Script nicht aus. Wenn ich dann in der CMD im PowerShell das SCRIPT1.ps1 manuell ausführe, klappt alles so, wie es soll.

Wie schaffe ich es nun, dass in der PowerShell das SCRIPT1.ps1 ausgeführt wird, ohne es jedes Mal manuell anstarten zu müssen?



Viewing all articles
Browse latest Browse all 2314


<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>