Passing string included dollar signs to -Replace Variable

后端 未结 4 493
心在旅途
心在旅途 2021-01-18 07:58

I am trying to replace a sentence in .config file using powershell.

${c:Web.config} = ${c:Web.config} -replace

\'$BASE_PATH$\\

4条回答
  •  滥情空心
    2021-01-18 08:41

    To Pass:

    $BASE_PATH$\Test\bin\$Test_TYPE$\WebTest.dll
    

    Change to:

    `"\`$BASE_PATH\`$\\Test\\bin\\\`$Test_TYPE\`$\\WebTest.dll"`
    

    Logic:

    • Before every dollar sign enter \`
    • Before every backslash enter another back slash \
    • Close string with double quotes ""

提交回复
热议问题