Managing vSphere with PowerCLI (creating Tags)

DownloadVMware vSphere PowerCLI is a command line tool for automating vSphere and vCloud management.

VMware PowerCLI is a very powerful command-line tool that lets you automate close to all aspects of a vSphere management. This includes among others: network, storage, guest OS.

PowerCLI is distributed as PowerShell modules, and includes over 500 PowerShell cmdlets.

The first version of PowerShell was released in November 2006 for Windows XP, Windows Server 2003 and Windows Vista. We have come a long way since then. PowerShell is an important part of today’s IT landscape. By using PowerShell you can manage systems from different vendors in a unified way. I find myself using PowerShell almost every day in my work.

To install the VMware vSphere PowerCLI you can use the following PowerShell code:

2020-11-18 14_56_39-192.168.0.103 - Remote Desktop Connection

Today we are going to create a Tag in vCenter assign it to the appropriate VM’s. A tag is a sort of label that you can apply to objects in your vSphere inventory. When you create a tag, you assign that tag to a category. Categories allow you to group related tags together for easier management. When you create a category, you can specify the object types for its tags, and whether more than one tag in the category can be applied to a single object. vSphere offer such flexibility and can simplify automation in your environment. For example, if you wanted to tag your virtual machines by guest operating system type, you can create a category called OS. You can then specify that it applies to virtual machines only and that only a single tag can be applied to a virtual machine at any time. Tags allowing you to create organizational groups that would otherwise not exist (company department, role…etc).

You can create tags to be assigned to All (default), Cluster,Datacenter, Datastore, DatastoreCluster, DistributedPortGroup, DistributedSwitch, Folder, ResourcePool, VApp, VirtualPortGroup, VirtualMachine, VM, VMHost.

TagCategory

Next we will create the actual tag.

Create Tag

Now that we have created a tag along with the assigned category we will assign the tag to the appropriate VM’s In this example we will assign the tag to the SQL servers in the environment.

Assign Tag

Next we can retrieve the machines by using the tag as filter.

Query Tag

Viewing the Tags and Tag Category from within vCenter

Overview

And the assigned machines.

TagCategory vcenter

Geef een reactie

Het e-mailadres wordt niet gepubliceerd. Vereiste velden zijn gemarkeerd met *