Powershell Remote Execution Error on EC2

amazon ec2powershell

I am trying to use powershell remote execution on a EC2 server. I have enabled Windows Remote Management on the Server and configured WRM with -quickconfigure.

However when run the example:

$Cred=Get-Credential Invoke-Command -Authentication Negotiate -Credential $Cred -ComputerName <servername>.eu-west-1.compute.amazonaws.com -ScriptBlock {Get-Culture}

I get the 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.
+ CategoryInfo : OpenError: (:) [], PSRemotingTransportException
+ FullyQualifiedErrorId : PSSessionStateBroken

I read here in a question that the Server and client both have to be on same domain. Is that really necessary? Do we have other options to interact with non-domain machine using Powershell?

Note: I am aware of PSExec tool.

Best Answer

The server and client do not need to be in the same domain, however, the error message you are getting seems to me to indicate not an authentication error, just a basic networking error. Are there firewalls between you and the WinRM server that may be preventing this communication? Can you telnet to port 5985 on the WinRM server? 5985 is the HTTP port that WinRM uses in 2008 R2.

edit: Also note that you're going to need to add the WinRM server to the TrustedHosts list on your client, but I don't think you've gotten to that point yet.