title: Difficulty escaping quote character in powershell script (Azure Devops Yaml)
body: <p>My azure piplines yaml script uses powershell to replace a placeholder string in a .CS file with the current date string. This is the line with the value to be replaced (<code>20200101000000</code>)</p>
  <pre><code>[assembly: MyCompany.Net.Attributes.BuildDateAttribute(&quot;20200101000000&quot;)]
  </code></pre>
  <p>This is the powershell step that does it</p>
  <pre><code>pwsh: (get-content -path $(versionFile)) | foreach-object {$_ -replace &quot;20200101000000&quot;, (get-date -f 'yyyyMMddhhmmss')} | set-content -path $(versionFile)
    displayName: 'Update time stamp file'
  </code></pre>
  <p>I want to alter this step to include the quote characters <code>&quot;</code> around the search string and write them into the new output value along with the new date.  But I cannot seem to  make that happen.</p>
  <p>I mistakenly tried just putting escaped quote characters <code>\&quot;</code> in the search and replace strings.  But I guess you cannot escape inside of a single-quoted string so it did not work</p>
  <pre><code>pwsh: (get-content -path $(versionFile)) | foreach-object {$_ -replace &quot;\&quot;20200101000000\&quot;&quot;, (get-date -f '\&quot;yyyyMMddhhmmss\&quot;')} | set-content -path $(versionFile)
  </code></pre>
  <p>This was the error:</p>
  <pre><code>##[command]&quot;C:\Program Files\PowerShell\7\pwsh.exe&quot; -NoLogo -NoProfile -NonInteractive -ExecutionPolicy Unrestricted -Command &quot;. 'D:\a\_temp\80625e52-1302-4e35-a799-223ab893bcf1.ps1'&quot;
  ParserError: D:\a\_temp\80625e52-1302-4e35-a799-223ab893bcf1.ps1:3
  Line |
     3 |  … lyInfo.cs) | foreach-object {$_ -replace &quot;\&quot;20200101000000\&quot;&quot;, (get-d …
       |                                                ~~~~~~~~~~~~~~~~~
       | Unexpected token '20200101000000\&quot;&quot;' in expression or statement.
  ##[error]PowerShell exited with code '1'.
  </code></pre>
  <p>I also tried to just using double quotes around the <code>get-date</code> part of the script so I could escape the quote characters but that doesn't seem to work either.  I'm guessing that's a limitation of writing script this way.</p>
  <p>Is there some other way to achieve what I want?</p>