PowerShell -command from batch Invoke-RestMethod
<p>I've tried every combination I can think of, but the best I can come up with is an encoding issue.  I know how to work around this by using -EncodedCommand or creating a small .ps1 script, but that's not what am looking for a couple of reasons.</p>

<p>So I hope, someone here knows what's going on here.</p>

<p>This works at PowerShell command prompt:</p>

<pre><code>Invoke-RestMethod -Uri "http://127.0.0.1:8989/api/series" -Method Get -Header @{"X-Api-Key" = "1234"}
</code></pre>

<p>But when I try to pass it from command prompt or batch it fails! </p>

<pre><code>powershell.exe -command "&amp; {Invoke-RestMethod -Uri "http://127.0.0.1:8989/api/series" -Method Get -Header @{ "X-Api-Key" = "1234" } }"

powershell.exe -command "&amp; Invoke-RestMethod -Uri "http://127.0.0.1:8989/api/series" -Method Get -Header @{ "X-Api-Key" = "1234" }"

powershell.exe -command Invoke-RestMethod -Uri http://127.0.0.1:8989/api/series -Method Get -Header @{ "X-Api-Key" = 1234 }

powershell.exe -command @{Invoke-RestMethod -Uri http://127.0.0.1:8989/api/series -Method Get -Header "X-Api-Key" = 1234 }
</code></pre>

<p>and many, many, many more combinations ;(</p>

<p><strong>update 160614</strong>
removed all the error examples, not needed anymore.</p>