【问题标题】:Running msdeploy.exe from within Powershell从 Powershell 中运行 msdeploy.exe
【发布时间】:2012-10-11 04:35:26
【问题描述】:

我正在尝试从 Powershell 中运行以下命令:

msdeploy -verb:sync -source:archiveDir=c:\KitchenPC\Build -dest:appHostConfig="KitchenPC",computerName=https://192.168.0.3:8172/msdeploy.axd,authType=Basic,userName=someuser,password="secret" -allowUntrusted

docs say 简单地将每个参数后的: 替换为=。所以我试过这个:

msdeploy -verb=sync -source=archiveDir=c:\KitchenPC\Build -dest=appHostConfig="KitchenPC",computerName=https://192.168.0.3:8172/msdeploy.axd,authType=Basic,userName=someuser,password="secret" -allowUntrusted

但是,我得到了错误:

错误:无法识别的参数 'computerName=https://192.168.0.3:8172/msdeploy.axd'。所有论据 必须以“-”开头。错误数:1。

我检查了docs on provider settings,但是他们没有提到它们等效的 Powershell 语法。

【问题讨论】:

标签: powershell msdeploy


【解决方案1】:

How do you call msdeploy from powershell when the parameters have spaces?

认为这已经回答了,只需修改它。 前任。使用变量包含“KitchenPC”和“secret”,并将 -dest 部分放在引号内。

工作示例:

msdeploy '-verb=sync' '-source=archiveDir=c:\KitchenPC\Build -dest=appHostConfig="KitchenPC",computerName=https://192.168.0.3:8172/msdeploy.axd,authType=Basic,userName=someuser,password="secret"' -allowUntrusted

(注意每个命令行参数的单引号)

【讨论】:

  • 是的,我已经看过那篇文章了。他们没有使用任何提供程序设置,因此它并不真正适用。博客文章中的解决方案基本上是编写一个产生cmd.exe 的函数,这可能是最好的解决方案。太糟糕了。
  • 哦,我明白你在说什么了。 this post 帮我弄清楚了,我已经更新了一个工作示例来回答你的问题。
  • 太棒了!许多其他博客文章和回复说这是不可能的,或者建议使用诸如调用 cmd 或 start-process 之类的组合。
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 2014-03-18
  • 2017-10-14
  • 1970-01-01
  • 1970-01-01
  • 2022-08-25
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多