title: PowerShell Invoke-Expression with ampersand in the command string
body: <p>I am trying to pass a variable with a string that contains an ampersand into Invoke-Expression, and it is telling me I have to put it in quotations and pass it as a string.</p>
  
  <p>I've tried multiple combinations of escaping and using a raw string and a string in a variable with combinations of "" and '' to no avail. How can I do it?</p>
  
  <p>Here's the code:</p>
  
  <pre><code>$streamout_calmedia01 = `
  "rtmp://75.126.42.216/livepkgr/calmedialive01?adbe-live-event=liveevent&amp;adbe-record-mode=record"
  
  $streamcmd_calmedia01 = "C:\avconv\usr\bin\avconv.exe 'rtmp://75.126.42.211/transcoder/mobileingest live=1' -f flv -c:v libx264 -r 30 -g 120 -b:v 410000 -c:a aac -ar 22050 -b:a 64000 -strict experimental -y $streamout_calmedia01"
  
  Invoke-Expression "$streamcmd_calmedia01"
  </code></pre>
  
  <p>I've tried using a <code>`</code> before the ampersand and using a double quotation in front of Invoke-Expression before putting in the variable,</p>
  
  <p>I've tried (as is shown) putting quotations around the variable with the <code>-Command</code> for Invoke-Expression and also putting '&amp;' and "&amp;" and concatenating the ampersand to the string.</p>
  
  <p>I need the ampersand in there for Flash Media Server to parse the command out of the stream name and flush prior recorded data before beginning HTTP live streaming chunking.</p>