20 abril 2015

VMware vSphere: how to create tags - Part II with PowerCLI

On the Part I post we learn how to add a Tag and a Category trough the GUI interface with vSphere Web Client, now, let´s take a look about how to do it with PowerCLI.


Remember that Tags are a new feature available from vSphere 5.1 and the cmdlets are available from PowerCLI 5.5, so, we need at least a vCenter on vSphere 5.1 and the PowerCLI 5.5 installed but much better use las version PowerCLI 6 (not all cmdlets are present in PowerCLI 5.5 initial release)

Use this to verify the version you have installed: 
PowerCLI C:\> Get-VIToolkitVersion


Now with the New-Tag we can review the Tags configured, and with "New-TagCategory" create a Category and after with "New-Tag" the Tag



Now, we are ready to assign Tags to objects, in this case to Virtual Machine:


It´s time to verify it trough Web Client:





Something i didn´t mention jet, is that you can assign multiple Tags to an objet in vSphere , in our case to a Virtual Machine. It means that you can for example tag a VM with the "DDBB_tag" because it´s a SQL DDBB, and Tag it with "Cluster_tag" because it´s a Microsoft Cluster, or with another tag like "Test_tag" because it´s a DDBB SQL Cluster from the Lab Environment.

Why multiple Tags? For vROps it will be useful to create custom groups using different Tags criteria and fix different policies if its a VM from DDBB servers, or if its a VM from Lan Environment..... one VM could be placed in different Custom Groups at the same time :-)


First Part of this post: VMware vSphere: how to create tags - Part I