Activate Windows Server 2016 Virtual Machines Using PowerShell Direct #HyperV #PowerShell #AVMA #WS2016


A while ago, I wrote a blog post on how to automatic activate Windows Server 2012 R2 Virtual Machines using PowerShell, you can read about it here.

The script was written based on Windows Server 2012 R2 guest virtual machines and requires PowerShell Remoting to be set for each VM. In other words, you need to have networking setup for each VM.

In Windows Server 2016 Hyper-V, Microsoft introduced an awesome feature called PowerShell Direct. For more information about PowerShell Direct, check here.

I updated the script to support Windows Server 2016 guest virtual machines, which does not require any network configuration for the guest operation system or any type of network at all.

In this post, I will show you how to leverage PowerShell Direct and Automatic Virtual Machine Activation (AVMA) to activate Windows Server 2016 guest operation systems.

Automatic Virtual Machine Activation

Automatic Virtual Machine Activation (AVMA) is a feature that was introduced in Windows Server 2012 R2. AVMA binds the virtual machine activation to the licensed virtualization server and activates the virtual machine when it starts up. This eliminates the need to enter licensing information and activate each virtual machine individually.

Microsoft has update the generic AVMA Keys to support Windows Server 2016 (Datacenter/Standard/Essentials) according to the Guest OS Edition that you want to activate, for more information, check here.

In order to get benefits of Automatic Virtual Machine Activation, AVMA requires that the host is running Windows Server 2016 Datacenter and that the guest virtual machine OS is either Windows Server 2016 Datacenter, Windows Server 2016 Standard or Windows Server 2016 Essentials.


You have deployed several Windows Server 2016 virtual machines on top of Windows Server 2016 Hyper-V (Datacenter Edition) with or without SCVMM or using a deployment tool such as MDT where you can add below script during the deployment to activate all VMs.

Of course you could use the manual approach, but the easiest way is to use PowerShell, for this reason I have created a small function that takes care of all the steps for you:

Here we go:

You can run above script from your management machine in the same domain, you need to specify first the Hyper-V host name this could be Nano Server host as well, and then you have two options, either you specify a single virtual machine name or you can use the switch “-ALLVMS” to activate all virtual machines on a single host.

This script will leverage PowerShell Remoting to connect to the Hyper-V host remotely and then use PowerShell Direct to activate all VMs. Welcome to Nested PowerShell Remoting (PSRemoting + PSDirect). This script will also use a new cmdlet in Hyper-V 2016 named “Wait-VM“. This cmdlet will wait for a virtual machine to respond using (heartbeat) before activating. You need to update the “Environment Configuration” section in the script to match your environment for admin credentials.

The results will look something like this:


In this example, we are activating all virtual machines on a single host, if a VM is already activated, you will be notified, and if a new VM needs to be activated, you will be notified as well.

There are different ways to accomplish the same result, but nevertheless it has worked for me and I feel that it’s a much easier than having to log in and activate each VM individually.

Enjoy your weekend!


About Charbel Nemnom 405 Articles
Charbel Nemnom is a Cloud Solutions Architect and Microsoft Most Valuable Professional (MVP), totally fan of the latest's IT platform solutions, accomplished hands-on technical professional with over 17 years of broad IT Infrastructure experience serving on and guiding technical teams to optimize performance of mission-critical enterprise systems. Excellent communicator adept at identifying business needs and bridging the gap between functional groups and technology to foster targeted and innovative IT project development. Well respected by peers through demonstrating passion for technology and performance improvement. Extensive practical knowledge of complex systems builds, network design and virtualization.

Be the first to comment

This site uses Akismet to reduce spam. Learn how your comment data is processed.