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

What is “Inside Microsoft Teams”?

“Inside Microsoft Teams” is a webcast series, now in Season 4 for IT pros hosted by Microsoft Product Manager, Stephen Rose. Stephen & his guests comprised of customers, partners, and real-world experts share best practices of planning, deploying, adopting, managing, and securing Teams. You can watch any episode at your convenience, find resources, blogs, reviews of accessories certified for Teams, bonus clips, and information regarding upcoming live broadcasts. Our next episode, “Polaris Inc., and Microsoft Teams- Reinventing how we work and play” will be airing on Oct. 28th from 10-11am PST.

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.
External Sharing and Guest User Access in Microsoft 365 and Teams

This 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.

You will learn:

  • Who should be allowed to be invited as a guest?
  • What type of guests should be able to access files in SharePoint and OneDrive?
  • How should guests be offboarded?
  • How should you determine who has access to sensitive information in your environment?

Sponsored by:

Live Webinar: Active Directory Security: What Needs Immediate Priority!Live on Tuesday, October 12th at 1 PM ET

Attacks on Active Directory are at an all-time high. Companies that are not taking heed are being punished, both monetarily and with loss of production.

In this webinar, you will learn:

  • How to prioritize vulnerability management
  • What attackers are leveraging to breach organizations
  • Where Active Directory security needs immediate attention
  • Overall strategy to secure your environment and keep it secured

Sponsored by: