0

I am working on pipeline where I am passing arguments in the powershell script as below. I want to append ServiceName and Environment.Name with a $ sign.

arguments: '-ServiceDisplayName "$(ServiceDisplayName)" -ServiceName "$(ServiceName)$(Environment.Name)" -ServiceDirectory "$(ServiceFolder)" -UserName "$(ServiceUserAccount)"'

Tried -ServiceName "$(ServiceName)`$$(Environment.Name)"

  • They can't be within single quotes. – js2010 Dec 09 '22 at 18:32
  • use backtick (grave) to escape them. Go through [THIS](https://stackoverflow.com/questions/32127583/expand-variable-inside-single-quotes) – Ranadip Dutta Dec 09 '22 at 18:36
  • @RanadipDutta tried this -ServiceName "$(ServiceName)`$$(Environment.Name)" doesn't work – Amersfoort Dec 09 '22 at 18:46
  • I guess what you want is `-ServiceDisplayName $ServiceDisplayName -ServiceName "$ServiceName$($Environment.Name)" -ServiceDirectory $ServiceFolder -UserName $ServiceUserAccount`. Note that you have to write a valid expression within `$(…)`, the sub-expression operator, so insert another `$` to reference a variable. Neither sub-expression nor quoting are necessary to pass a single variable. – zett42 Dec 09 '22 at 20:24
  • Use single quotes instead of double quotes. Single quotes will not replace the dollar sign with a variable. – jdweng Dec 10 '22 at 10:07

0 Answers0