Posts

Showing posts from March, 2017

Get admin password of Windows EC2 instances programmatically with AWS PowerShell

Image
The most common method to get the local admin password of a Windows EC2 instance is though the AWS web console. We highlight the instance in the web console, upload the private key, and then password is shown. It's pretty convenience for a few. But... imagine if you have to do the same for 60, 80 or hundreds of instances. Such a drag, eh? The AWS PowerShell tool has a cmdlet to help addressing the drag. With the Get-EC2PasswordData  cmdlet and the proper private keys, we can retrieve the decrypted password from AWS. The cmdlet doesn't support multiple queries so we'd have loop the queries in case of multiple instances. I would imagine that's the case anyway. The PowerShell code snippet below demonstrates how to query for windows EC2 instances, retrieve the local admin password for each one of them and output information for each instance as an object. Assuming we've already configured the AWS PowerShell credentials and have the private keys (*.PEM files). R