Administering EC2 instance with Windows Powershell

I'm having trouble administering a Windows 2k8 Server SP2 instance (hosted on EC2) with powershell from my Windows 7 client. When I try to run:

Invoke-Command {Get-Service} -ComputerName ec2-184-73-111-34.compute-1.amazonaws.com

I receive the following error:

Connecting to remote server failed with the following error message : 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. For more information, see the about_Remote_Troubleshooting Help topic.

On the server I have: (1) Connected with RDP (the server is reachable), and (2) run Enable-PSRemoting

On my client I have: (1) Added the EC2 instance to TrustedHosts

I've also tried running the above command on the server with the Windows firewall completely disabled, but that didn't solve the problem either. I've also verified there's a firewall exception for Windows Remote Management.

The tutorial I've been referencing is: http://blogs.iis.net/thomad/archive/2010/08/12/managing-windows-amazon-ec2-machines-remotely-with-powershell.aspx


On EC2, you need to open port 5985, the default WinRM remoting port on your security group so that you can connect to the instance from your IP address.

On the instance in the cloud, do a:

winrm quickconfig -quiet

On your workstation:

set-item wsman:\localhost\Client\TrustedHosts -value "*" -force
Invoke-Command {Get-Service} -ComputerName <hostname> -Credential administrator

And that should get you going.


Both of those machines must be on the same domain. I don't see how you have accomplished that. "On my client I have: (1) Added the EC2 instance to TrustedHosts." does not suffice. You would need to add the EC2 server to your ground based Domain, or have the EC2 server be the domain controller for that Windows7 client.

Another approach to "managing" that EC2 server from the ground would be to utilize PsExec.exe from Microsoft's "SysInternals" collection of utilities. You would find that gem in their "PsTools" bundle of free tools. So, on the Microsoft download site appropriate for you, search for PsTools and PsExec is in there.

PsExec let's you remotely control machines that are outside of your domain.