Hyper-V|Virtualization|Windows Server 2016

Hyper-V Virtual Machine Groups

cloud computing IT pro

In this post, I will show you how you can use virtual machine groups on Windows Server 2016 Hyper-V to manage a set of virtual machines. This includes adding support for operational actions on VHDX Sets, such as Hyper-V Replica.



Sponsored Content

Read the Best Personal and Business Tech without Ads

Staying updated on what is happening in the technology sector is important to your career and your personal life but ads can make reading news, distracting. With Thurrott Premium, you can enjoy the best coverage in tech without the annoying ads.

What Are Virtual Machine Groups

Let’s say that you had a set of one or more virtual machines that you wanted to perform some repeatable tasks against. Maybe you need to perform an orchestrated action. An example of this would be enabling Hyper-V Replica against a pair of virtual machines that share some VHDX Sets, such as shared VHDX v2.0. We can use virtual machine groups to perform these actions.

Creating a Virtual Machine Group

All virtual machine group actions are performed using PowerShell. There is no GUI option in Hyper-V Manager. The relevant cmdlets identify virtual machines only by the object and not by the name. In larger deployments such as a private cloud, virtual machine names can be reused by different tenants or customers.

Make note, failover clustering has a different kind of group for ordering the failover of virtual machines.

We can create a new virtual machine group using the New-VMGroup cmdlet. The -type flag is instructing Hyper-V to create a virtual machine group. We also have another type called a management group, which we will look at later.

New-VMGroup -Name "CrmDBClu" -GroupType VMCollectionType

I can add a single virtual machine to this new group. This is shown below. I am using the name of the virtual machine to return the virtual machine object, which is what we added to the group.
Add-VMGroupMember -Name "CrmDBClu" -VM (Get-VM "VM1")

Alternatively, I can add a pair of virtual machines.
Add-VMGroupMember -Name "CrmDBClu" -VM (Get-VM "VM1"),(Get-VM "VM2")

We can query what virtual machines are in a group.
(Get-VMGroup -Name "CrmDBClu").VMMembers

We can also query what the group memberships are for the virtual machines.
Get-VM | FT Name, Groups

We can use this group to perform orchestrated actions. The following is an example of enabling Hyper-V Replica for virtual machines that use shared VHDX files. Notice that we substituted the name of the virtual machine being replicated with the list of members from the virtual machine group.
Enable-VMReplication -VM (Get-VMGroup CrmDBClu).VMMembers -ReplicaServerName DRHost -ReplicaServerPort 80 -AuthenticationType Kerberos -CompressionEnabled 1 -ReplicationFrequencySec 30 -AutoResynchronizeEnabled 1

The above is how you can replicate virtual machines using VHDX Sets in a supported manner.

Virtual Machine Management Groups

It is possible to create a group of groups. Think about having a 3-tier application:

  • Web servers in a virtual machine group
  • Application servers in a second virtual machine group
  • Database servers in a third virtual machine group

You can add all three virtual machine groups into a single management group. First, we create a management group.

New-VMGroup -Name "MgmtGroup" -GroupType ManagementCollectionType

Then, we can add existing virtual machine groups into this management group.
Add-VMGroupMember -VMgroup (Get-VMGroup "MgmtGroup") -VMGroupMember (Get-VMGroup "CrmDBClu")


Right now, virtual machine groups are only something that we might use with Hyper-V Replica or to replace an array in a script. Virtual machine groups live on after a script ends. I have the feeling that we are just seeing the glimpse of what virtual machine groups might offer in the future.


Don't have a login but want to join the conversation? Sign up for a Petri Account

Comments (0)

Leave a Reply

Aidan Finn, Microsoft Most Valuable Professional (MVP), has been working in IT since 1996. He has worked as a consultant and administrator for the likes of Innofactor Norway, Amdahl DMR, Fujitsu, Barclays and Hypo Real Estate Bank International where he dealt with large and complex IT infrastructures and MicroWarehouse Ltd. where he worked with Microsoft partners in the small/medium business space.

Download this eBook!

External Sharing and Guest User Access in Microsoft 365 and Teams

his eBook will dive into policy considerations you need to make when creating and managing guest user access to your Teams network, as well as the different layers of guest access and the common challenges that accompany a more complicated Microsoft 365 infrastructure. The eBook will also outline some of the major decision points across four general-purpose guest access policy scenarios for how an organization can set this up with standard licensing.

Download Now

Sponsored By