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 |
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") |
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 |
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 |
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 |
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") |
To Verify that the groups have nested ok, use:
# Verify Group nesting | |
(Get-VMGroup -Name "CRM_APP").VMGroupMembers |
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.
[AdSense-A]
0 Comments