By using a Windows Server feature called Automatic Virtual Machine Activation (AVMA), administrators can easily activate virtual machines (VMs) running on an already-licensed Windows Server Data Center Edition server.

In this article, we're going to cover three ways to use AVMA to activate a VM. But first, let's see how we can figure out the licensing state of a VM. To do this, we can log into the console of the VM and use the slmgr tool by running slmgr /dli. In the screenshot below, we're looking at an unlicensed VM, noting the "Notification" status.

VM not activated

VM not activated

Activating on the command prompt ^

Now that we've confirmed the status, we can use AVMA to activate the VM. Our first method is with a command prompt. With your command prompt still open as an administrator, type slmgr /ipk <ProductKey>. You can find the keys we'll be using in this article on the Microsoft Automatic virtual machine activation page.

When you hit Enter, you'll get a message showing the activation has succeeded.

Successful activation

Successful activation

After activation, we can confirm activation by running slmgr /dli again, and this time the status shows licensed.

Windows is licensed

Windows is licensed

The message also has an expiration date. This licensing check prevents you from moving the VM to a host that is not running on a licensed Windows Server Data Center host. It checks in every few days, and as long as the VM is still running on the allowed host, it resets the expiration date.

Now we'll go back to an unlicensed VM. As you can see with slmgr, notice the message is a little different this time because I'm showing a VM that has no key at all instead of one with an invalid KMS key like I showed last time.

Product key not found

Product key not found

Activating with PowerShell ^

Our second activation method is going to be with PowerShell. This performs the same action of activating via the command line, but it is an alternative way to make it happen. To do this, open PowerShell as an administrator and enter slmgr /ipk <ProductKey>. When you hit Enter, you'll get the same message as before, showing that the key was successful, and just like before, we can run slmgr /dli to confirm that it did work.

Remote activation ^

Not only can you activate VMs via logging into their respective consoles but you can also do this remotely using PowerShell Remoting. To do this, we'll find another unlicensed VM to test with. I've found a VM called AVMA1 I'd like to license. From my remote client, I'll run slmgr again, but this time, I need to do a few things differently.

Since we'll be using PowerShell Remoting and more specifically, the Invoke-Command command, we must wrap our code into a scriptblock. However, due to the way PowerShell Remoting invokes command-line utilities in a remote session, we need to get a little more specific in how to execute slmgr. Since slmgr is a VBscript, when it's running locally, Windows automatically uses wscript to execute the script, but in a remoting session, you've got to get more explicit and call the command-line interpreter cscript followed by the full path of the slmgr script.

Invoke-Command -ComputerName AVMA1 -ScriptBlock { cscript C:\Windows\System32\slmgr.vbs /ipk <ProductKey>}

Once this completes, you'll then get a console output saying the license has been activated instead of the pop-up. Since we're running this remotely, the pop-up isn't an option, thus requiring us to use cscript.

Subscribe to 4sysops newsletter!

Successful activation via Invoke Command

Successful activation via Invoke Command

The bottom line ^

Activating local or remote Windows Servers using the command line is a simple and efficient way to manage license activations across all of your servers hosted on Windows Server Data Center edition. Using the command line is a great way to activate many VMs at once.


Leave a reply

Your email address will not be published.


© 4sysops 2006 - 2022


Please ask IT administration questions in the forums. Any other messages are welcome.


Log in with your credentials


Forgot your details?

Create Account