I have an instance of Amazon EC2.
Using powershell on my local workstation, I want to be able to remotely delete my Amazon EC2 instance and execute some commands.
I found a lot of articles on the Internet, but no one works, or I misunderstood them (maybe the last one).
Some I tried are Managing Windows EC2 instances remotely using Powershell
Administering an EC2 Instance Using Windows Powershell
Inclusion-PSRemoting
How to run PowerShell commands on remote computers
I understand what I need:
Amazon EC2 Dashboard > Network & Security > Security Groups > Add port 5985 //Local & EC2 PowerShell(Administrator) enable-psremoting -force //Local PowerShell(Administrator) set-item wsman:\localhost\Client\TrustedHosts -value "*" -force $password = convertto-securestring -asplaintext -force -string myPassword $credential = new-object -typename system.management.automation.pscredential -argumentlist "myUsername", $password $session = new-pssession ec2-00-00-00-000.compute-1.amazonaws.com -credential $credential enter-pssession $session
But I get this error
new-pssession : [ec2-00-00-00-000.compute-1.amazonaws.com] Connecting to remote server ec2-00-00-00-000.compute-1.amazonaws.com failed with the following error message : WinRM cannot complete the operation. Verify that the specified computer name is valid, that the computer is accessible over the network, and that a firewall exception for the WinRM service is enabled and allows access from this computer. By default, the WinRM firewall exception for public profiles limits access to remote computers within the same local subnet. For more information, see the about_Remote_Troubleshooting Help topic. At line:1 char:12 + $session = new-pssession ec2-00-00-00-000.compute-1.amazonaws.com -credential $c ... + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + CategoryInfo : OpenError: (System.Manageme....RemoteRunspace:RemoteRunspace) [New-PSSession], PSRemotin gTransportException + FullyQualifiedErrorId : WinRMOperationTimeout,PSSessionOpenFailed
powershell amazon-web-services amazon-ec2
Th4t guy
source share