【发布时间】:2023-03-15 01:41:01
【问题描述】:
我正在尝试编写脚本以使用 MSdeploy 同步 IIS 服务器。
我尝试了所有可能的方法来运行 .exe,但有时我会收到此错误:
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.
当我在第一次运行后再次执行相同的脚本时,它工作正常。我最终是这样称呼它的:
& 'C:\Program Files\IIS\Microsoft Web Deploy V3\msdeploy.exe' -verb:sync ...
任何想法如何防止它第一次失败?
【问题讨论】:
-
您的脚本中是否有可能正在修改 PATH 环境变量,以便在第二次执行时,PowerShell 能够找到 msdeploy.exe?
标签: powershell webdeploy invoke-command