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.
So I hope, someone here knows what's going on here.
This works at PowerShell command prompt:
Invoke-RestMethod -Uri "http://127.0.0.1:8989/api/series" -Method Get -Header @{"X-Api-Key" = "1234"}
But when I try to pass it from command prompt or batch it fails!
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" }"
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 }
and many, many, many more combinations ;(
update 160614 removed all the error examples, not needed anymore.