Powershell Invoke-RestMethod “Unable to connect to the remote server”
i write simple powershell script post json string server. have strange issue when execute script.
-
the server inside our intranet, firewall disable intranet server. server uses http , no authentication required.
-
i tried execute script in different places:
- powershell window in own computer (windows 7, powershell 5)
- powershell ise in computer
- start powershell.exe in command prompt in own computer
-
start powershell.exe in third party command prompt application in own computer
-
powershell window in citrix seesion (windows 10, powershell 5)
- start powershell.exe in command prompt in citrix seesion
i checked of 6 places have executionpolicy "remotesigned",
but, can execute script in last 3 places,
in first 3 place, error
invoke-restmethod : unable connect remote server @ f:\temp\test.ps1:46 char:9 + $resp = invoke-restmethod -method post -body $result ... + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + categoryinfo : notspecified: (:) [invoke-restmethod], webexception + fullyqualifiederrorid : system.net.webexception,microsoft.powershell.com mands.invokerestmethodcommand
a few more information:
- i tried invoke-webrequest, got same error message.
- if have fiddler open, can execute script post in first 3 places.
- in command prompt, can post server using curl.exe. if enter powershell mode in same console, couldn't using invoke-restmethod same server
any idea why happen, should information?
hi bigyellow,
>>any idea why happen, should information?
it helpful troubleshooting issue if post related scripts here.
i couldn't test @ moment.
we test issue on our environment if long script.
thanks again posting here.
best regards,
andy_pan
please remember mark replies answers if , unmark them if provide no help. if have feedback technet subscriber support, contact tnmff@microsoft..com.
Windows Server > Windows PowerShell
Comments
Post a Comment