Powershell aus MSDeploy RunCommand Laufen nicht beendet
-
26-09-2019 - |
Frage
Im versuch MSDeploy zu bekommen einen Powershell-Skript auf einem Remote-Server auszuführen. Dies ist, wie ich MSDeploy ausführen:
msdeploy \
-verb:sync \
-source:runCommand='C:\temp\HelloWorld.bat', \
waitInterval=15000,waitAttempts=1 \
-dest:auto,computername=$WebDeployService$Credentials -verbose
HelloWorld.bat enthält:
echo "Hello world!"
powershell.exe C:\temp\WebDeploy\Package\HelloWorld.ps1
echo "Done"
Die HelloWorld.ps1 nur enthält:
Write-Host "Hello world from PowerShell!"
Allerdings scheint es, wie Powershell beendet nie. Dies ist die Ausgabe von Ausführen des MSDeploy:
Verbose: Performing synchronization pass #1.
Verbose: Source runCommand (C:\temp\HelloWorld.bat) does not match destination (C:\temp\HelloWorld.bat) differing in attributes (isSource['True','False']). Update pending.
Info: Updating runCommand (C:\temp\HelloWorld.bat).
Info:
Info: C:\temp>echo "Hello world!"
"Hello world!"
C:\temp\WebDeploy>powershell.exe C:\temp\HelloWorld.ps1
Info: Hello world from Powershell!
Info:
Warning: The process 'C:\Windows\system32\cmd.exe' (command line '/c "C:\Users\peter\AppData\Local\Temp\gaskgh55.b2q.bat
"') is still running. Waiting for 15000 ms (attempt 1 of 1).
Error: The process 'C:\Windows\system32\cmd.exe' (command line '/c "C:\Users\peter\AppData\Local\Temp\gaskgh55.b2q.bat"'
) was terminated because it exceeded the wait time.
Error count: 1.
Wer weiß eine Lösung?
Lösung
Ihr Szenario und Problem Blick ähnlich wie dieses gemeldeten Problem: PowerShell.exe kann hängen, wenn STDIN umgeleitet
Wenn dies der Fall ist, dann versuchen Sie diese Abhilfe: Verwendung -inputformat none
:
powershell.exe -inputformat none C:\temp\WebDeploy\Package\HelloWorld.ps1
Das habe ich versucht, mit „einer Fälschung MSDeploy“ Programm, das die .bat-Datei wie folgt aufruft:
using System.Diagnostics;
class Program
{
static void Main(string[] args)
{
ProcessStartInfo si = new ProcessStartInfo();
si.FileName = "cmd.exe";
si.Arguments = "/c " + args[0];
si.RedirectStandardInput = true;
si.UseShellExecute = false;
var process = Process.Start(si);
process.WaitForExit();
}
}
tut Diese Demo das gleiche Problem haben, dass Sie beschreiben und die Abhilfe hilft. Wenn msdeploy
die .bat-Datei in gleicher oder ähnlicher Weise ruft dann hoffentlich ist dies eine Lösung.
Andere Tipps
powershell.exe -file ScriptFile.ps < CON
Das das Problem lösen, ohne zu undokumentierten Features zurückzugreifen.