내가 생각할 수있는 모든 조합을 시도했지만 가장 좋은 것은 인코딩 문제입니다. 나는 -EncodedCommand를 사용하거나 작은 .ps1 스크립트를 작성하여이 문제를 해결하는 방법을 알고 있지만 몇 가지 이유를 찾고있는 것은 아닙니다.PowerShell -command from batch Invoke-RestMethod
여기 누군가가 여기에서 무슨 일이 일어나고 있는지 알고 있기를 바랍니다.
이 PowerShell 명령 프롬프트에서 작동합니다
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 }
powershell.exe -command @{Invoke-RestMethod -Uri http://127.0.0.1:8989/api/series -Method Get -Header "X-Api-Key" = 1234 }
많은, 많은, 더 많은 조합;. (
갱신 160614 제거 모든 오류 예, 더 이상 필요하지
[this] (http://stackoverflow.com/a/34282945)를 참조하십시오. – PetSerAl