title: PowerShell command over multiple lines
body: <p>I have a batch script that looks like this:</p>
  <h3>Test.bat</h3>
  <pre><code>@echo off
  
  :: Starts a PowerShell session that starts a PowerShell process with administrator privileges
  powershell -noprofile -command &quot;&amp;{$process = start-process powershell -ArgumentList '-noprofile -noexit -file GetTools.ps1' -verb RunAs -PassThru;$process.WaitForExit();}&quot;
  </code></pre>
  <p>I would like to split up the code inside the &quot;&amp;{ ... }&quot; over multiple line for readability.</p>
  <p><a href="https://stackoverflow.com/questions/2608144/how-to-split-long-commands-over-multiple-lines-in-powershell">This</a> post says that using a trailing backtick should do the trick, but when I write:</p>
  <pre><code>powershell -noprofile -command &quot;&amp;{`
      $process = start-process powershell -ArgumentList '-noprofile -noexit -file GetTools.ps1' -verb RunAs -PassThru;`
      $process.WaitForExit();`
  }&quot;
  </code></pre>
  <p>...that is, I end each line with a trailing backtick, then I get the following error:</p>
  <pre><code>Incomplete string token.
  At line:1 char:4
  + &amp;{` &lt;&lt;&lt;&lt;
      + CategoryInfo          : ParserError: (`:String) [], ParentContainsErrorRecordException
      + FullyQualifiedErrorId : IncompleteString
  
  '$process' is not recognized as an internal or external command,
  operable program or batch file.
  '$process.WaitForExit' is not recognized as an internal or external command,
  operable program or batch file.
  '}&quot;' is not recognized as an internal or external command,
  operable program or batch file.
  </code></pre>
  <p>What am I doing wrong?</p>
  <p><strong>SOLUTION:</strong></p>
  <pre><code>powershell -noprofile -command &quot;&amp;{&quot;^
      &quot;$process = start-process powershell -ArgumentList '-noprofile -noexit -file C:\Dev\Powershell\Sandbox.ps1' -verb RunAs -PassThru;&quot;^
      &quot;$process.WaitForExit();&quot;^
      &quot;}&quot;
  </code></pre>