Powerful AWS Bot for automation using Telegram Bot API written in PowerShell

Sometimes back I was working on a free notification system using Telegram Bot (https://telegram.org/blog/bot-revolution), and I wrote a simple function in PowerShell, which could be use in various ways for sending instant notification to any smartphone for free (http://bit.ly/2ys1gF5).

I thought what else we could do with it, and I have got an idea to use it as AWS Automation Bot to perform simple tasks. I have created a set of instructions for a Bot using PowerShell script which we could use to perform the following tasks instantly instead of doing it from AWS console.

  1. Getting instance details using instance name.
  2. Getting attached volume details using instance name.
  3. Getting list of the available snapshots for a instances using instance name.
  4. Getting the console screenshot for troubleshooting using instance name.
  5. Getting the console log for troubleshooting using instance name.
  6. Start an instance using instance name.
  7. Stop an instance using instance name.
  8. Restart an instance using instance name.

Continue reading

Cleanup disabled users from AD Group/s

Cleanup disabled accounts from groups is one of the most boring job, and also take lots of time. Manually it’s almost impossible to maintain. Recently I had a request to perform such task for many groups, so, I wrote a script to do it automatically on behalf of me. I am now sharing this script, hoping this might help you as well.


This script will do following task automatically.

  • Get the members of a group.
  • Identify only users.
  • Identify disabled users.
  • Check every disabled users group memberships.
  • Remove the disabled users from that group.
  • Generate a report with status (success / failure).
  • Keep the report on your desktop.

Re-enabling Network Adapter in Azure VM (Resource Manager)

It is very common that sometimes we disabled the network adapter from VM to trouble shoot some network related issue, and after doing so we suddenly realize that we made a big mistake, especially if we do it on Azure VMs. Suddenly we lost all the communication to the VM, no RDP, no PowerShell, and VM got completely isolated from the network. If AWS, we could fix this very easily by adding one additional network adapter (ENI), but in Azure, it will be little bit tricky, coz currently Azure VM does NOT support adding or removing NICs after a VM is created, Multi-NIC can only be applied when a VM is created. So, fixing this will be bit trickier for Azure VMs. If you search “Disabled network card on Azure VM“, you will get multiple solution, but unfortunately those are not working with newer Azure VM (Resource Manager).

To fix this issue, you have to follow the steps bellow, and you will be able to re-enable the adapter.

  • Select VM from http://portal.azure.com
  • Select Network interfaces
  • Select IP configurations
  • Change the Static IP to Dynamic and Save the settings
  • Wait till configuration gets updated.
  • Now again change it from Dynamic to Static and also change the IP Address to a new one for the same VNET and Save.
  • This will reboot the instance and after some time you will get the ping response from the new IP.
  • Now you have to follow the exact same steps to change the IP back to old one.
  • And finally you will able to get the VM with old IP.
  • If you wish, buy me a cup of coffee.