Posts

Showing posts from 2017

Quick review on my career after learning PowerShell

I have been an operator through our my IT career, clicking through the software install, user/ machine provisioning, and checking logs until I learned PowerShell. At first, I started scripting many of the repetitive tasks, and then some complex ones. They generated regular Active Directory/ file system/ Exchange reporting, scanned for cryptolocker affected files in file shares, and audited Exchange user attributes for the entire company. Things got wild after having a bunch of PowerShell scripts laying around in my local folders. Now I look back, it seems the path evolved so naturally. I needed a way to manage the PowerShell scripts and their history safely. So I started using Git. I wanted to work with others on my team and we had peer reviews. Spinning up VMs/ Cloud instances were then became bottlenecks in the workflow so configuration management and Infrastructure as code were embraced. Secret management, logging and monitoring, automated backup and recovery.... more and more w

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