“Open-EC2” PowerShell cmdlet (RDP + PS)

To save time I wrote a quick PowerShell function to open RDP and a remote PowerShell console for Amazon EC2 machine instances. Example screenshots are below.    Enjoy!  Hot

 

Function Open-EC2($server, $user, $pass)
{
  Write-Host "- saving RDP credential" -ForegroundColor Blue
  cmdkey /generic:TERMSRV/$server /user:$user /pass:$pass
  Write-Host "- opening RDP" -ForegroundColor Blue
  mstsc /v:$server 
  
  $secure = ConvertTo-SecureString $pass -asplaintext -force
  $cred = New-Object System.Management.Automation.PSCredential $user,$secure
  Set-Variable -Name c -Value $cred -Scope global
  Write-Host "- opening PSSession" -ForegroundColor Blue
  New-PSSession -computername $server -credential $c -Authentication Negotiate
}

 

image

image

image

Return to Top ▲Return to Top ▲