title: Powershell remoting: Cannot connect to Windows 2012 EC2 Instance
body: <p>I'm trying to use a windows 7 client to try to remotely control a Windows Server 2012 EC2 instance with an elastic IP attached. It's the default configuration, so the WinRM services should be up and running, but for good measure, I've also run the following commands on the server:</p>
  
  <pre><code>Set-ExecutionPolicy -ExecutionPolicy RemoteSigned -Scope CurrentUser -Force 
  set-item WSMan:\localhost\Client\TrustedHosts -Value * -Force
  set-item WSMan:\localhost\Shell\MaxMemoryPerShellMB -Value 0 -Force
  Enable-PSRemoting
  </code></pre>
  
  <p>On the client, I've then run </p>
  
  <pre><code>$remoteUsername = "##########" 
  $remotePassword = "#######"
  $remoteHostname = "00.000.000.00" #this is my elastic IP
  $securePassword = ConvertTo-SecureString -AsPlainText -Force $remotePassword
  $cred = New-Object System.Management.Automation.PSCredential $remoteUsername, $securePassword
  
  test-WSman -computername "54.252.195.14"
  </code></pre>
  
  <p>But the result I get back is </p>
  
  <pre><code>Connect-WSMan : The WinRM client cannot complete the operation within the time specified. Check if the machine name is valid and is reachable over the network and firewall exception for Windows Remote Management service is enabled. 
  At ***************.ps1:14 char:14
  + Connect-WSMan &lt;&lt;&lt;&lt;  -Credential $cred $remoteHostname
      + CategoryInfo          : InvalidOperation: (*********) [Connect-WSMan], InvalidOperationException
      + FullyQualifiedErrorId : WsManError,Microsoft.WSMan.Management.ConnectWSManCommand
  </code></pre>
  
  <p>I've then tried to run the following code on the client as well, but that hasn't helped either:</p>
  
  <pre><code>Set-ExecutionPolicy -ExecutionPolicy RemoteSigned -Scope CurrentUser -Force 
  set-item WSMan:\localhost\Client\TrustedHosts -Value * -Force
  set-item WSMan:\localhost\Shell\MaxMemoryPerShellMB -Value 0 -Force
  Enable-PSRemoting
  </code></pre>
  
  <p>There isn't a lot of info out there in terms of how to get windows AMIs running and automated on EC2, is anyone able to help me figure out the error here? The client and server are not on the same domain, but I thought changing the trustedhosts would make it possible to remotely connect anyway?</p>
  
  <p><strong>UPDATE</strong></p>
  
  <p>After following Barak's advice below, I was able to establish a telnet connection from the server to itself on the right port, but only when using the private IP, and not when using the elastic IP. </p>
  
  <p>The Security rules are as follows: </p>
  
  <p>-1  icmp    0.0.0.0/0<br>
  22  tcp 0.0.0.0/0<br>
  443 tcp 0.0.0.0/0<br>
  3389    tcp 0.0.0.0/0<br>
  5985    tcp 0.0.0.0/0<br>
  5986    tcp 0.0.0.0/0<br>
  8888    tcp 0.0.0.0/0   </p>