/VMware: How to create and use VMs TAGs – Part 1

VMware: How to create and use VMs TAGs – Part 1

Today we will explain how to use the VMware feature TAGs in the VMs and create Veeam Backup Jobs using TAGs. Since this article is too long, I will create the second article for this Veeam tasks.

In this article, we will focus on creating and using TAGs (and category TAGs), in a second article will explain how to use the same TAGs in Veeam and create Veeam Backup Jobs using TAGs.

What are VM TAGs?

TAGs in VMware exists since version 5.1 but are a feature not very advertise (in my opinion), and only some VMware customers used it.

Tags can create custom labels and or metadata and apply them to any object with the vCenter inventory.  TAGs purpose is to identify an object by adding metadata to the object.

TAGs are used for better management of our Virtual Infrastructure. With TAGs, we can group VMs (as an example) by category(like Guest OS, Clusters, multiple vCenter. We can Backup VMs by Guest OS and quickly identify the Guest OS in the VMs with a script.

We can also use the Search in vSphere Web Client to find objects by TAGs.

We can also use it to identify a VM by applying (like DNS, SQL, Exchange, or another type of Application). For environments with thousands of VMs, TAGing is an effortless way to manage and organize our VMs(or other objects).

If you manage and host a Datacenter for several customers, TAGing VMs or Clusters by Customers will also be easy to manage your Virtual Environment.

We can manage, search, or group VMs using TAGing regardless of where they are located (like a folder, Pool, host, or even vCenter when using multiple vCenters)

VMware Notes:With vSphere 6.0, vSphere tags are no longer stored in the Inventory Service database table as the source of truth. They are relocated to the vCenter Server’s database (VCDB) table CIS_KV_Keystore and the VMware Directory Services (Lotus) Service Provider tagging. After the tag association is created, this information is then pulled into the Inventory Service database for display within the vSphere Web Client.”

Some extra information about TAGs: KB:2130130

TAGs are set by Category and then by TAG with a Category.

We can TAG at the following object level:

  • Cluster
  • Datacenter
  • Datastore
  • Datastore Cluster
  • Distributed Port Group
  • Distributed Switch
  • Folder
  • Host
  • Network
  • Resource Pool
  • vApp
  • vCO Scheduled Workflow
  • vCO Workflow
  • Virtual Machine

What will we use in our article?

In our case, we only TAG VMs and create a Category for the Guest System Operation (OS).

There will be a TAG Category call ‘Guest OS’

Name               Cardinality        Description
—-                     ———–               ———–
Guest OS        Single                   VMs System Operation TAG

Inside of this Category, we will have the type of TAGs OS.
These are the type of TAGs that VMs will have depending on the Guest System Operation.

Name                Category             Description
—-                      ——–                   ———–
Linux                Guest OS             Linux Virtual Machine
Windows          Guest OS             Windows Virtual Machine
Other OS          Guest OS             Other OS Virtual Machine

Note: TAGs can only be added or checked using vSphere Web Client. vSphere Client Tool will not provide TAGs information.

How to create TAGs?

TAGs can only be created using the vSphere Web Client. This article will focus on how to create TAGs using PowerCli scripts and in the vSphere Web Client tasks.

Note: In this example, we will only use TAGing for VMs. Like we stated above, we can TAG most of the objects in the vCenter.

How to create TAGS using vSphere Web Client

Create TAG Category:

TAGCategory

As we can see in the image above, we have the TAG option when connecting to the vSphere Web Client in the left menu.

Then we choose TAG Category (you cannot create a TAG without first create a TAG Category).

Options:

Category Name: The category name must be unique to the currently-selected vCenter Server system.
Description: You can provide text in the description to describe the purpose or usage of the category.
Cardinality:

>Select 1 tag per object to allow only one tag from this category to be applied to an object at any one time.

Use this option for categories whose tags are mutually exclusive. For example, a category called Priority with tags High, Medium, and Low should allow one tag per object because it should have only one priority.

>Select Many tags per object to allow multiple tags from the category to be applied to an object at any one time.

Use this option for categories whose tags are not mutually exclusive.

After you have set the cardinality of a category, you can change the cardinality from 1 tag per object to Many tags per object, but not from Many tags per object to 1 tag per object.

Associable Object Types:

Select whether tags in this category can be assigned to all objects or only to a specific type of managed object, such as virtual machines or datastores.

After you have set the associable object types for a category, you can change a category associated with a single object type to be associable with all object types. Still, you cannot restrict a category associated with all object types to associate with a single object type.

Note: In our example, we have associated the TAG Category to Virtual Machines

After creating the TAG Category, we can then create TAGs linked to the TAG Category created above.

Create TAGs:

TAGs

Options:

TAG Name: Choose the name for your TAG. TAG name needs to be unique inside of the same TAG Category.
TAG Category: Choose a TAG Category (created in the previous task) from the TAG Category list.
Description: You can provide text in the description to describe the purpose or usage of these TAGs.

Assign/Add the TAG in VMs:

TAGs00

In the vSphere Client, go to the Virtual Machines section and click in the VM to add the TAG.

As we can see above, the VM summary will show a TAG area. Then click Assign (1)

If we click Mouse right-click in the list of our VMs, we also have the VM menu, and there is the option to assign a TAG to the VM.

Screen Shot 06-10-16 at 12.34 AM

 

 

 

 

 

 

 

 

Directly in the VM Summary or VM menu options, will open the next Window to choose the VM TAG to assign.

TAGs02

 

 

 

 

 

 

 

Then we need to choose one of the VMs TAGs that exists. In this case, is a Windows VM, so we will select the Windows TAG and click Assign.

TAGs01

After we can see the TAG already been assigned to this VM.

After all these tasks, we have created TAG Category, TAGs, and assign TAGs to our VMs using the vSphere Web Client.

How to create TAGS using PowerCli scripts?

In the next section, we will create the same TAG Category, same TAGs, and assign TAGs to all our VMs by automatically checking the type of Guest OS that VM is running.

Note: Since not all VMs can have VMware tools installed, checking Guest OS without VMware Tool cannot be 100% accurate. In that case, we will check the Guest OS that the user chooses when created the VM.

Let’s explain a little bit our script and how to use PowerCli commands to create TAGs.

Create TAG Category:

This line creates the ‘Guest OS’ Category adding the description and choosing Cardinality single (since we will only use it for VMs).

The script will always check if there is already a TAG ‘Guest OS,’ if yes, will skip this section. We are using this for our example, but you can change the script and put whatever TAG Category you need in your environment.

Create TAGs:

This line creates the TAGs using the TAG Category created in the previous section.
Previously has already set the TAGs names that we need for our environment.

Again the script will always check if these TAGs already exist. If yes will skip this section. This is just for our example; you can change the script and put whatever TAG you need in your environment. Just change the $TAGNames array for whatever you need in your environment.

Assign/Add the TAG in VMs:

Then the script will check all VMs in the vCenter to see if the VMs Guest OS, after knowing the Guest OS will check if there is a TAG assigned already to the right OS. If not, will assign a Guest OS TAG to the VM according to Guest OS used.

Note: We also use the option by Cluster that you can use or comment on running in all Clusters in the vCenter.

The script will create an HTML report of all changes made (new TAG Category created, new TAGs created and all VMs assigned to the right TAG). I Will also send it by email (you need to change the script in the email settings, according to your email server)

This is the full script:

With the script, we finish the first part of this TAGs article in VMware and Veeam Backup.

We will focus on using the same VMs TAGs in Veeam and creating Backup Jobs by VM TAG in our second part.

Final Note: I will like to thank my colleague Vladimir Sokol for his excellent help in improving the script. Thank you for all your support on this.

Important Note: This script and article are provided as-is. No warranty is provided or implied. The author is NOT responsible for any damages or data loss that may occur by using these tasks or scripts included here in this article.

Second article: How to create and use VMs TAGs in Veeam Backup Jobs

Note: Share this article if you think it is worth sharing.

©2017 ProVirtualzone. All Rights Reserved

By | 2021-01-01T18:09:51+01:00 June 10th, 2016|Backups Posts, Partners, Veeam, VMware Posts|1 Comment

About the Author:

I have over 20 years of experience in the IT industry. I have been working with Virtualization for more than 15 years (mainly VMware). I recently obtained certifications, including VCP DCV 2022, VCAP DCV Design 2023, and VCP Cloud 2023. Additionally, I have VCP6.5-DCV, VMware vSAN Specialist, vExpert vSAN, vExpert NSX, vExpert Cloud Provider for the last two years, and vExpert for the last 7 years and a old MCP. My specialties are Virtualization, Storage, and Virtual Backup. I am a Solutions Architect in the area VMware, Cloud and Backup / Storage. I am employed by ITQ, a VMware partner as a Senior Consultant. I am also a blogger and owner of the blog ProVirtualzone.com

One Comment

  1. […] Home/Backups, Virtualization/Veeam: How to create and use VMs TAGs in Veeam Bakup Jobs – Part 2 Previous […]

Leave A Comment