Powershell Invoke-RestMethod "Unable to connect to the remote server"
<p>I write a very simple powershell script to post a json string to server. I have a strange issue when I execute the script. </p>

<ol>
<li><p>The server is inside our intranet, the firewall is disable for all intranet server. </p></li>
<li><p>I tried to execute the script in different places:  </p>

<ul>
<li>Powershell window in my own computer <strong>(windows 7, powershel 5)</strong></li>
<li>Powershell ISE in my computer</li>
<li>start powershell.exe in a command prompt in my own computer</li>
<li><p>start powershell.exe in a third party command prompt application in my own computer</p></li>
<li><p>Powershell window in a citrix seesion <strong>(windows 10, powershel 5)</strong></p></li>
<li>start powershell.exe in a command prompt in a citrix seesion </li>
</ul></li>
</ol>

<p>I checked all of 6 places have ExecutionPolicy "RemoteSigned",</p>

<p>But, I can only successfully execute the script in last 3 places, </p>

<p>In first 3 place, I get an error </p>

<pre><code> Invoke-RestMethod : Unable to connect to the remote server
 At 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
</code></pre>

<p>Besides, I also tried <code>Invoke-WebRequest</code>, I got same error message. </p>

<p>Any idea why this is happen? What should I do with it?</p>