Reading Time: 3 minutes
Share:
Twitter
LinkedIn
Facebook
Reddit
Whatsapp
Follow by Email

With Windows Server 2016 we have some cool new features within Hyper-V. One of them are Hyper-V Virtual Machine Groups. In this post I am going to explain what Virtual Machine Groups are and how to create them.

What are Hyper-V Virtual Machine Groups?

First thing to note is that there are two different types of Hyper-V Virtual Machine Groups; Virtual Machine Collection Group and Management Collection Group.

A Virtual Machine Collection Group is just a logical collection of virtual machines of your choosing. This type of group is designed to make it as easily possible for you to carry out tasks on a number of Virtual Machines, instead of carrying out the task on separately on each individual Virtual Machine.

Management Collection Groups are a logical collection of Virtual Machine Collection Groups. This type of group is designed to allow you to nest both Virtual Machine Collection Groups and Management Collection Groups, to allow you to manage Virtual Machines of multi-tier applications. This is useful for scenarios such as Hyper-V Replica and also Backup.
 
We have some new PowerShell commands added into the Hyper-V module to help us create the new groups:

Add-VMGroupMember
Get-VMGroup
New-VMGroup
Remove-VMGroup
Remove-VMGroupMember
Rename-VMGroup
 

Creating a Virtual Machine Collection Group

To create a Virtual Machine Collection Group is really easy. Just open PowerShell with elevated permissions on the Hyper-V host and type:

# Create new VM Group
New-VMGroup -Name "BackEnd" -GroupType VMCollectionType -Verbose
view raw Hyper-V_Groups.ps1 hosted with ❤ by GitHub

To add some Virtual Machines to the new group we just created, you just need to type the following:

# Add VMs to VM Collection Group
Add-VMGroupMember -Name "BackEnd" -VM (Get-VM "SQL01"),(Get-VM "SQL02")
view raw Hyper-V_Groups.ps1 hosted with ❤ by GitHub

This has just added SQL01 and SQL02 to the BackEnd Virtual Machine Collection Group. You can edit the code above to add just one Virtual Machine or many.

To verify that the Virtual Machines are in the group you can use:

# Verify Group Members
(Get-VMGroup -Name "BackEnd").VMMembers
view raw Hyper-V_Groups.ps1 hosted with ❤ by GitHub

To find out what group a Virtual Machine is a member of you can use:

# Find group VM is member of
Get-VM | FT Name, Groups -autosize
view raw Hyper-V_Groups.ps1 hosted with ❤ by GitHub

Creating a Management Collection Group

To create a Management Collection Group is really easy. Just open PowerShell with elevated permissions on the Hyper-V host and type:

# Create a Management Group
New-VMGroup -Name "CRM_APP" -GroupType ManagementCollectionType
view raw Hyper-V_Groups.ps1 hosted with ❤ by GitHub

To add Virtual Machine Collection Groups to the Management collection group you can use:

# Nest Groups to Management Group
Add-VMGroupMember -VMgroup (Get-VMGroup "CRM_APP") -VMGroupMember (Get-VMGroup "FrontEnd"), (Get-VMGroup "BackEnd")
view raw Hyper-V_Groups.ps1 hosted with ❤ by GitHub

To Verify that the groups have nested ok, use:

# Verify Group nesting
(Get-VMGroup -Name "CRM_APP").VMGroupMembers
view raw Hyper-V_Groups.ps1 hosted with ❤ by GitHub

And that’s it! You can now go about using Hyper-V Groups in you scripts. Hyper-V Groups are still a new thing and I am sure that we will start to see more uses for them soon. Look out for future posts where I am using them.

Share:
Twitter
LinkedIn
Facebook
Reddit
Whatsapp
Follow by Email

Pixel Robots.

I’m Richard Hooper aka Pixel Robots. I started this blog in 2016 for a couple reasons. The first reason was basically just a place for me to store my step by step guides, troubleshooting guides and just plain ideas about being a sysadmin. The second reason was to share what I have learned and found out with other people like me. Hopefully, you can find something useful on the site.

0 Comments

Leave a Reply

Your email address will not be published. Required fields are marked *

*

I agree