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.

  1. the server inside our intranet, firewall disable intranet server.

  2. i tried execute script in different places:

    • powershell window in own computer (windows 7, powershel 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, powershel 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

besides, tried invoke-webrequest, got same error message.

any idea why happen? should it?

i had similar issue few days , resolved applying proxy settings in "invoke-webrequest" call.

something this;

invoke-webrequest -uri $url -proxy 'http://10.10.7.11:80' -proxycredential $creds 

Comments

Popular posts from this blog

Spring Boot + JPA + Hibernate: Unable to locate persister -

go - Golang: panic: runtime error: invalid memory address or nil pointer dereference using bufio.Scanner -

c - double free or corruption (fasttop) -