【问题标题】:Adding dollar sign in front of variable name in arguments of Powershell script在 Powershell 脚本的参数中的变量名前添加美元符号
【发布时间】:2022-12-10 12:21:48
【问题描述】:

我正在处理管道,我在 powershell 脚本中传递参数,如下所示。我想在 ServiceName 和 Environment.Name 后附加一个 $ 符号。

参数:'-ServiceDisplayName "$ServiceDisplayName)" -ServiceName "$(ServiceName)$(Environment.Name)" -ServiceDirectory “$(ServiceFolder)”-用户名“$(ServiceUserAccount)”'

尝试过 -ServiceName“$(ServiceName)`$$(Environment.Name)”

【问题讨论】:

  • 它们不能在单引号内。

标签: powershell environment-variables pipeline azure-powershell dollar-sign


【解决方案1】:

只需添加额外的$-ServiceDisplayName "$($ServiceDisplayName)" ... 如果您在单引号字符串中调用,依此类推。

也请继续发布脚本,我们将能够更好地提供帮助,而不仅仅是参数部分。因为可能还有其他字符串处理问题。

【讨论】:

    猜你喜欢
    • 2012-09-05
    • 2011-12-17
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2013-03-13
    • 1970-01-01
    • 2011-10-13
    相关资源
    最近更新 更多