【问题标题】:powershell web.deploy.cmd positional parameterpowershell web.deploy.cmd 位置参数
【发布时间】:2014-02-10 15:39:37
【问题描述】:

我在使用 powershell、Web 部署和转义命令路径时遇到了大问题。我正在尝试使用 Web Deploy 中的 runCommand 提供程序在部署之前运行 powershell 脚本。但是,即使我用双引号括起来,powershell 似乎也将带有空格的路径解释为单独的参数。

这就是我运行时的输出

web.deploy.cmd /y

Info: Updating runCommand (powershell.exe -ExecutionPolicy Bypass invoke-command "C:/local dev/mobile/Core/Web services/wsAuthUser/mobilestability/src/wsAuthUser/obj/Debug/Package/PackageTmp/install/installboot.ps1" -computername server01 -argumentlist Mobile2/AuthUser, pre).

但错误是:

Warning: Invoke-Command : A positional parameter cannot be found that accepts a
gument '

Warning: dev/mobile/Core/Web'.
At line:1 char:15

为什么整个路径都用引号引起来抱怨?

更新:

如果我将以下内容粘贴到 Powershell ISE:

invoke-command "C:\group dev\mobile\Core\Web Services\wsAuthUser\mobilestability\src\wsAuthUser\obj\Debug\Package\PackageTmp\bin\install\installboot.ps1" -computername dev-mob2iis01 -argumentlist Mobile2/AuthUser, pre

它运行良好,没有错误。

如果我随后打开命令提示符,则通过相同的命令,但预先添加 powershell 和执行策略参数,如下所示:

powershell.exe -ExecutionPolicy Bypass invoke-command "C:\localdev\mobile\Core\Web Services\wsAuthUser\mobilestability\src\wsAuthUser\obj\Debug\Package\PackageTmp\bin\install\installboot.ps1" -computername server01 -argumentlist Mobile2/AuthUser, pre

又失败了。

【问题讨论】:

    标签: powershell powershell-2.0 webdeploy


    【解决方案1】:

    因为它是 windows,而不是 unix。因此,您将使用反斜杠作为文件路径,而不是常规斜杠。

    更新: 您只需使用引号即可使其通过 cmd 工作

    powershell.exe -ExecutionPolicy Bypass -command "invoke-command 'C:\localdev\mobile\Core\Web Services\wsAuthUser\mobilestability\src\wsAuthUser\obj\Debug\Package\PackageTmp\bin\install\installboot.ps1' -computername server01 -argumentlist Mobile2/AuthUser, pre"
    

    【讨论】:

    • 我刚刚尝试了反斜杠和双反斜杠,我得到了同样的错误??
    • "C:\local dev\mobile\Core\Web services\wsAuthUser\mobilestability\src\wsAuthUser\obj\Debug\Package\PackageTmp\install\installboot.ps1" ... 没有理由不应该工作,做一个resolve-path 以确保它存在
    • 好的,它应该是 \bin\install\installboot.ps1 - 但这对错误没有影响。 Powershell 不工作时很糟糕!我花了一整天的时间来解决这个问题。该错误肯定是在“本地开发”之后拆分路径
    • 我可以说试试invoke-command -Filepath "C:\path to\file\script.ps1" .. 但我很困惑你的错误是什么,或者你此时试图运行什么命令。也许用更多信息更新您的帖子,以便我可以提供帮助
    • 我已经更新了我上面的帖子。出于某种原因,从命令行运行并在开头带有一些额外参数会导致问题。
    猜你喜欢
    • 1970-01-01
    • 2012-09-04
    • 1970-01-01
    • 1970-01-01
    • 2017-05-07
    • 2015-05-21
    • 1970-01-01
    • 2017-11-06
    • 2016-05-27
    相关资源
    最近更新 更多