2010-11-21 13 views
16

원격 서버에서 PowerShell 스크립트를 실행하도록 MSDeploy를 얻으려고합니다.MSdeploy runcommand에서 PowerShell을 실행하지 못했습니다.

echo "Hello world!" 
powershell.exe C:\temp\WebDeploy\Package\HelloWorld.ps1 
echo "Done" 

HelloWorld.ps1에만 포함되어 있습니다 :

msdeploy \ 
    -verb:sync \ 
    -source:runCommand='C:\temp\HelloWorld.bat', \ 
    waitInterval=15000,waitAttempts=1 \ 
    -dest:auto,computername=$WebDeployService$Credentials -verbose 

HelloWorld.bat은 포함이 내가 MSDeploy를 실행하는 방법이다 PowerShell을 종료 결코처럼

Write-Host "Hello world from PowerShell!" 

그러나, 그것은 보인다. 이것은 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. 

누구나 해결책을 알고 있습니까?

+0

그것에 대한 전체 소스 코드가 포함 된 최종 해결책은 무엇입니까? – Kiquenet

답변

20

시나리오와 문제점이보고 된 문제와 유사 :이 경우 다음이 해결 방법을 시도 할 경우 PowerShell.exe can hang if STDIN is redirected

: -inputformat none 사용

powershell.exe -inputformat none C:\temp\WebDeploy\Package\HelloWorld.ps1 

나는 "가짜 msdeploy에 이것을 시도 ".bat 파일을 다음과 같이 호출하는 프로그램입니다.

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(); 
    } 
} 

이 데모에는 당신이 기술하고 해결 방법이 도움이됩니다. msdeploy이 .bat 파일을 동일하거나 유사한 방법으로 호출하면 잘하면 해결 방법입니다.

+1

-inputformat 아무도 문제를 해결하지 못했습니다! 감사! –

+1

Powershell 2.0 및 3.0 [documentation] (http://technet.microsoft.com/en-us/library/hh847736.aspx)에 따르면 'None'은 유효한'-InputFormat' 인수가 아니므로이 해결 방법이 될 수 있습니다. 정의되지 않은 동작에 의존합니다. –

2
powershell.exe -file ScriptFile.ps < CON 

이렇게하면 문서화되지 않은 기능을 사용하지 않고도 문제를 해결할 수 있습니다.

+2

이것은 실제로 무엇을합니까? – Doug

관련 문제