How to solve Failed-Activating Windows in AWS EC2

Sometimes when I create a Windows EC2 Instance from one of my custom AMIs I get an activation failed Windows Server.

Follow the instruction below to Activate your Windows Instance. (For Windows Server 2016, 2019 and later only).

Activate Windows Manually using EC2Launch initialization script

Open Powershell on your Windows Server and run the command below.

C:\ProgramData\Amazon\EC2-Windows\Launch\Scripts\InitializeInstance.ps1; cscript "${env:SYSTEMROOT}\system32\slmgr.vbs" /ato

Notes:

  • No need to run Powershell in administrator mode.
  • No need to restart your instance. Once you run the above command, the Activate Windows on your desktop will disappear.
  • This will not update the local Administrator password

There are other ways to Activate Windows on your AWS EC2. You can check them all here.

Adding a Volume without Restart in Windows EC2

When I create Windows Instances in AWS EC2, I usually forget to add a drive or two. With this step-by-step tutorial, I will walk you through how to create a new Volume for EC2 Instances, then make Windows use the new Volume without a reboot.

  • Initial Setup
  • Creating and Attaching the Volume in AWS EC2 Console
  • Adding the new Volume to Windows System

Initial Setup

I launched a EC2 Windows 2016 Server with only 1 Block Device (/dev/sda1), which is also my Root Device.

AWS EC2 Console

Note the Availability Zone where your instance is located, you will need this later. Mine is in us-east-1a.

Looking inside Windows it only has 1 volume.

File Explorer
Disk Management

Creating and Attaching the Volume in AWS EC2 Console

Now we need to attach a new Volume for our Windows Server.

Go to AWS EC2 Console, on the left sidebar click on Volumes.

Continue reading Adding a Volume without Restart in Windows EC2

Adding a Secondary Active Directory Domain Controller on Windows Server 2016

After setting up an Active Directory (AD) on our Windows Server it is advisable to have another server to be a Secondary Active Directory Domain Controller to become the failover for Active Directory in case something happens to the first AD Server.

Below is a detailed tutorial on how to properly set up a Secondary Active Directory Domain Controller on Windows Server 2016.

Note

Primary refers to the first Windows Server that we setup Active Directory with.

Secondary refers to the the Second Windows Server we will set Active Directory. This is what we will setup here.

Here are the major steps that we need to do

Setup

Testing


Setup

Primary: Get the IP Address of the Primary Active Directory Domain Controller

Login to your Primary Active Directory Windows Server.

Right-click on the Window Icon on the bottom-left of the screen. Then click Command Prompt.

On the command prompt window type ipconfig then Enter.

Note the IPv4 Address. You will need this later on the Secondary Windows Server. Continue reading Adding a Secondary Active Directory Domain Controller on Windows Server 2016

Change Password for Active Directory Administrator on Windows Server 2016

The very first thing I do after installing Active Directory (AD) on Windows Server is to change the password of my AD Administrator. I do this because I use Amazon Web Services (AWS) EC2 as my servers and AWS automatically generates the password for my Windows Server.

The AD Administrator is a very powerful user for Active Directory as you can restrict or open capabilities to other users and computer, install/uninstall programs and can even shut down any member computer using the Admin user. That is why you should really keep your AD Administrator User password in a safe place.

Whatever the reason you have for wanting to change the password of your AD Administrator below is a step-by-step tutorial on how to change it.

Login to your Windows Server.

Click on the Window Icon on the bottom-left and click on Server Manager.

Click on Tools then Active Directory Users and Computers.

Click on the ‘>‘ sign beside your domain on the left sidebar. This will expand the tree. Continue reading Change Password for Active Directory Administrator on Windows Server 2016

Configure Active Directory on Windows Server 2016

Below are detailed instructions on how you can setup Active Directory on your Windows Server 2016.

Sections on installing Active Directory.

Note: You can only do the steps below if you are an Administrator of your Windows Server.

Change the Computer Name

This is an optional step, but I would highly encourage you to do this so that your computer name will not be like EC2AMAZ-3TVT1HF, but a more descriptive one.

In this case since I am going to use the computer that we will setup as an Active Directory Domain Contoller I shall name my Windows Server as DC01.

In fact, you will have a lot of problem if you rename your computer after installing Active Directory. So better do it now before continuing to the next step.

Follow the steps on my post to change the Computer Name of your Windows Server 2016.

For now check the System Information page of the Windows Server.

Note the Workgroup.

Install Active Directory Feature

Now that we have updated the Computer Name of our Windows Server we can now start installing Active Directory.

Click on the Window Icon on the bottom-left side of the screen. Click Server Manager from the Menu.

On the Server Manage Window click on Add roles and features. Continue reading Configure Active Directory on Windows Server 2016

Changing the Computer Name of Windows Server 2016

Every time I launch a Windows Server on AWS or Google Cloud it always provides a random Computer Name. As a good practice I always want my computers to be named descriptively.

In this case I would like to update my Windows Server 2016 Computer Name to DC01, which means Domain Controller 01, since I will be using this server for Active Directory.

Below is a step by step guide on how to rename my Windows Computers to a more descriptive name.

Renaming the Windows Computer

Right-click on the Window Icon on the lower-left of the screen. Then click on System.

On the System Information Window, under Computer name, domain, and workgroup settings click on Change settings.

Continue reading Changing the Computer Name of Windows Server 2016

Installing MySQLdb for Python 3 in Windows

My favorite Python connector for MySQL or MariaDB is MySQLdb, the problem with this connector is that it is complicated to install on Windows!

I am creating this article for those who want to install MySQLdb for Python 3 for Windows. Especially me, since each time I am doing a Python project that needs to connect to MariaDB or MySQL I always look on how to install MySQLdb.

If you are interested why I prefer MySQLdb compared to other MySQL connectors you may want to read the comparison of MySQL-connector and MySQLdb from Charles Nagy.

Problems with installing MySQLdb on Windows

You can actually install MySQLdb using pip. See pypi documentation here.

pip install MySQL-python

Unfortunately, the pypi documentation is already out of date with the latest release was on Jan 3, 2014. Continue reading Installing MySQLdb for Python 3 in Windows

Making an Off-Screen Window Appear in Windows 10

When opening a program in Windows, sometimes it would open itself in a position outside of the screen. Right-clicking the program on the taskbar does not work. Trying to move it to a new desktop is also futile. Using window key+arrow keys is also not making it appear. What to do then?

Below is a way to make the off-screen window appear again.

  1. Click the off-screen program icon on the Windows Taskbar to make it the active window.

    I selected Powerpoint as my active window (highlighted).

    Continue reading Making an Off-Screen Window Appear in Windows 10

Showing “Open with Atom” when right clicking File or Folder in Windows 10

When right clicking on the File or Folder in Windows Explorer, the context menu will not show “Open with Atom” as an option. Because of this a user would need to open Atom Text Editor then Add Project Folder to see the Folder Tree on the side bar. Quite a lot of steps really.

Having a “Open with Atom” would be a time saving feature.

Context Menu for Folders

 

Context Menu for Files

The Context Menu is the menu that you can see every time you right-click a file or folder in Windows Explorer or Windows Desktop.


Is there a way to add “Open with Atom” on the context menu when you right click on a file or folder?

Yes, there is. Follow the instructions below. Continue reading Showing “Open with Atom” when right clicking File or Folder in Windows 10

How to use Synergy on Raspberry Pi

I have always used Synergy when using multiple computers since I do not want to use a lot of hardware (mouse and keyboard) to control all my unit. When I first received a Raspberry Pi the first thing I did was make Synergy work.

Here is the configuration that I use when working with Raspberry Pi.

  • Client – Raspberry Pi (to be controlled)
  • Server – Laptop where the mouse and keyboard will be used (Windows/Mac)

Screenshot of Synergy on a Windows computer.

1. Installing Synergy on Raspbian

Open the terminal and run the code below.

sudo apt-get install synergy

This will install Synergy on the Raspberry Pi along with its dependencies.

Continue reading How to use Synergy on Raspberry Pi