Skip to main content

VMware Tagging and Why You Should Care

VMware Tags were introduced with vSphere 5.1, and replace the legacy Custom Attributes feature from earlier versions. Tags allow you to add valuable metadata to every object in your inventory, which makes them searchable and sortable by those tags. How can this be used, you ask? Well I’ll tell you how I use tags.

I use tags to control which backup a virtual machine is a part of, to control the settings that should be applied during the backup, to identify the priority of virtual machines for business continuity and disaster recovery purposes, to define the patch group the virtual machine is in, to identify server roles and installed applications, to create dynamic groups of machines in Turbonomic Operations Manager. One of the guys on my team even built a dynamic list of servers on our SharePoint site that allows us to see at a glance every server in our environment and filter it to find the information we need quickly.

What is a Category?
Categories allow you to group related tags together. When you define a category, you can also specify which object types its tags can be applied to and whether more than one tag in the category can be applied to an object.

What is a Tag?
A tag is a label that you can apply to objects in the vSphere inventory. When you create a tag, you assign that tag to a category.

Now that you know what a category and a tag are, how do you create them and make them useful?

Step 1: Create a Category
When creating a tag category, you must allowed vCenter Inventory Service.vCenter Inventory Service Tagging.Create Inventory Service Tag privilages on the root vCenter Server. To create a tag category:

  1. From the vSphere Web Client Home, click Tags.
  2. Click the Items tab and then click Categories.
  3. Click the New Category icon.
  4. Edit the category options.
    OptionDescription
    Category NameThe category name must be unique to the currently-selected vCenter Server system.
    DescriptionYou can provide text in the description to describe the purpose or usage of the category.
    CardinalitySelect 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 an object 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 ObjectSelect 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 that is associable with a single object type to be associable with all object types, but you cannot restrict a category that is associable to all object types to being associable to a single object type.
  5. Click OK.

Step 2: Create a Tag
When creating a tag, you must be allowed vCenter Inventory Service.vCenter Inventory Service Tagging.Create Inventory Service Tag privilages on the root vCenter Server. To create a tag:

  1. From the vSphere Web Client Home, click Tags.
  2. Click the Items tab and then click Tags.
  3. Click the New Tag icon.
  4. In the vCenter Server drop-down menu, select the vCenter Server instance on which to create this tag.
  5. In the Name text box, enter a name for the tag.
  6. (Optional) In the Description test box, enter a description for the tag.
  7. In the Category drop-down menu, select an existing category or create a new category.
    If you select [New Category], the dialogue box expands to show the options for creating a category.
  8. Click OK.

Step 3: Assign a Tag to an Object
After you’ve created your tags, you can apply them as metadata to objects in the vSphere Web Client inventory. When assigning a tag, you must be allowed vCenter Inventory Service.vCenter Inventory Service Tagging.Create Inventory Service Tag privilages on the root vCenter Server. To assign a tag:

  1. Browse to the object in the vSphere Web Client inventory.
  2. Click the Manage tab and then click on Tags.
  3. Click the Assign Tag icon.
  4. (Optional) From the Categories drop-down menu, select a category to limit the tags displayed to tags from a specific category.
  5. Select a tag from the list.
  6. Click OK.

So you have a tag assigned to an inventory object, what can you do with tags?

  1. You can search for a specific tag to get a list of inventory objects with that tag.
  2. You can filter for a specific tag to only display inventory objects with that tag.
  3. You can use tagging to identify specific inventory objects in scripts.

Managing Categories and Tags with PowerCLI
One of the most useful things about tagging your environment is using those tags to manipulate objects in your inventory. Lets start simple.

If you want to return a list of all of the tags you’ve added to your environment:

Get-Tag

If you want to list all of the virtual machines with the tag Test:

Get-VM -Tag "Test"

If you want to list all of the assigned tags for an entity:

Get-TagAssignment -Entity "ENTITY-NAME"

If you want to assign a tag to an object:

New-TagAssignment -Tag "Test" -Entity "TEST-VM01"

If you want to remove a tag from an object:

Remove-TagAssignment -Tag "Test" -Entity "TEST-VM01"

If you want to be prompted for each tag before you remove it:

Get-VM "TEST-VM01" |Get-TagAssignment |Remove-TagAssignment

If you want to look at all of the available commands PowerCLI offers for tags:

Get-Command -PSSnapin VMware.VimAutomation.Core *Tag*

Those are just a few examples to get you started. If you have important tags in your environment, I’d suggest you devise a way to automate adding those tags to new virtual machines. Tagging will ultimately make your life easier, and allow you to interface with a growing list of 1st and 3rd party applications, scripts and more.

VMware Docs: Tagging Objects

  • Latest Posts
Infrastructure Architect

Scott is an experienced professional and recognized leader specializing in the design and implementation of enterprise virtualization, enterprise storage, server infrastructures and operations. A self-starter able to work both independently and in a team-oriented environment, Scott has a proven ability to create and automate solutions to improve productivity, reliability and performance.

Throughout his professional career, Scott has proven successes implementing technology and service improvement initiatives and has a demonstrated ability to think strategically about business, create technical definition around objectives in complex situations, develop solution strategies, motivate and mobilize resources, and deliver end-to-end technology solutions.

Scott has achieved multiple industry recognized certifications in virtualization, networking, cloud, storage, converged infrastructure, hyperconverged infrastructure and other technologies, and is honored to be a VMware vExpert in 2018-2022, and vExpert EUC 2020-2022.

Achievements

VMware vExpert EUC 2020-2022
VMware vExpert 2022
VMware vExpert 2021
VMware vExpert 2020
VMware vExpert 2019
VMware vExpert 2018

Double VCP – Data Center Virtualization & Desktop Mobility
Double VCP – Data Center Virtualization & Cloud Management
Double VCP – Data Center Virtualization & Network Virtualization
Double VCP – Network Virtualization & Desktop Mobility
Double VCP – Network Virtualization & Cloud Management
Double VCP – Cloud Management & Desktop Mobility

Dell Technologies Proven Professional Exam Developer – 2021

Certifications

VMware Certified Associate – Digital Business Transformation 2020
VMware Certified Professional – Desktop and Mobility 2020
VMware Certified Professional – Data Center Virtualization 2020
VMware Certified Professional 6 – Desktop and Mobility
VMware Certified Professional 6 – Cloud Management and Automation
VMware Certified Professional 6 – Network Virtualization
VMware Certified Professional 6 – Data Center Virtualization
VMware vSphere 6 Foundations
Dell Technologies Cloud Platform Administrator 2020
Dell Technologies Virtual Desktop Infrastructure 2019
Dell Technologies Specialist – Infrastructure Security Version 1.0
Dell Technologies Specialist – Systems Administrator, VxRail Appliance Version 2.0
Dell Technologies Specialist – Systems Administrator, VxRail Appliance Version 1.0
Dell Technologies Associate – Converged Systems and Hybrid Cloud Version 2.0
Dell Technologies and VMware Co-Skilled Associate – Converged Systems and Hybrid Cloud
IBM Enterprise Design Thinking Practitioner
IBM Enterprise Design Thinking Co-Creator
SolarWinds Certified Professional

Spread the love!

Scott Forehand

Scott is an experienced professional and recognized leader specializing in the design and implementation of enterprise virtualization, enterprise storage, server infrastructures and operations. A self-starter able to work both independently and in a team-oriented environment, Scott has a proven ability to create and automate solutions to improve productivity, reliability and performance. Throughout his professional career, Scott has proven successes implementing technology and service improvement initiatives and has a demonstrated ability to think strategically about business, create technical definition around objectives in complex situations, develop solution strategies, motivate and mobilize resources, and deliver end-to-end technology solutions. Scott has achieved multiple industry recognized certifications in virtualization, networking, cloud, storage, converged infrastructure, hyperconverged infrastructure and other technologies, and is honored to be a VMware vExpert in 2018-2022, and vExpert EUC 2020-2022.