代码之家  ›  专栏  ›  技术社区  ›  David S.

how to include a “:” as a parameter in powershell?

  •  1
  • David S.  · 技术社区  · 14 年前

    i have a simple powershell script, like this

    sqlcmd -S. -E -Q 'select ''$(x)''' -v x="c:a"
    

    but i always got the error message

    Sqlcmd: ':a': Invalid argument. Enter '-?' for help.
    

    我知道那是 ":" 在争论中引起了问题,但我不知道如何逃脱它。

    谢谢, 戴维

    3 回复  |  直到 13 年前
        1
  •  3
  •   David S.    14 年前

    sorry that i have to answer to my own question again.

    例如,$A=“abc”+“:123”

        2
  •  0
  •   Sharath Satish    13 年前

    您也可以尝试我们用于编写xdt:transforms脚本的这种方法。

    $xmlSection.SetAttribute("xdtTransform","Insert")

    然后

    foreach-object {$_ -replace "xdtTransform" , "xdt:Transform"}

        3
  •  -1
  •   Warren Rumak    14 年前

    后引号字符是PowerShell中的转义代码。所以写`:`…

    哎呀。。。这对冒号字符不起作用。使用 %3A 相反。