문제

I am trying to script something to sync up IIS servers using MSdeploy.

I tried all the possible ways to run the .exe but sometimes I get this error:

The term 'C:\Program Files\IIS\Microsoft Web Deploy V3\msdeploy.exe' is 
not recognized as the name of a cmdlet, function, script file, or 
operable program. Check the spelling of the name, or if a path was included, 
verify that the path is correct and try again.

When I execute the same script again after running it the first time it works fine. This is how I ended up calling it:

& 'C:\Program Files\IIS\Microsoft Web Deploy V3\msdeploy.exe' -verb:sync ...

Any ideas how to prevent it from failing the first time?

올바른 솔루션이 없습니다

다른 팁

Why dont you use the powershell cmdlets provided by Web Deploy instead of using the exe? These cmdlets get installed by default since V3.

I generally recommend that people use the Start-Process cmdlet to call external executables.

$MsDeploy = 'C:\Program Files\IIS\Microsoft Web Deploy V3\msdeploy.exe';
$ArgumentList = '-verb:sync ... ... ...';
Start-Process -FilePath $MsDeploy -ArgumentList $ArgumentList -Wait -NoNewWindow;

Keep in mind that C:\Program Files gets redirected for 32-bit processes, so

  1. Make sure you're starting the same process bitness for powershell.exe (or whatever is hosting PowerShell).
  2. Use $env:ProgramFiles for a more robust script and put it in quotes along with the full path since the path will likely have spaces in it.

To always use the 32-bit powershell process, on a 32-bit machine run:

%SystemRoot%\system32\WindowsPowerShell\v1\powershell.exe

On a 64-bit machine, run:

%SystemRoot%\SysWOW64\WindowsPowerShell\v1\powershell.exe
라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top