I am working on enhancing my vSphere release tagging script with the ability to tag the vCenter with a human-readable release name. As shown in the screenshot, it’s easy enough in the UI.

Image Caption
Tags applied to the vCenter in the UI

However, in PowerCLI there is no commandlet like get-vcenter. After many tries I gave up trying to force the object returned from

$global:DefaultVIServers[0]

to accept any tag-related operations. Today, I had the idea of working backwards from the assigned tags with Get-TagAssignment

Image Caption
The returned PowerCLI entity for vCenter tags

Yet, the returned entity puzzled me - I didn’t know about the entity type “Datacenters” (only Datacenter). Finally, my dear old friend get-member gave me the answer:

Image Caption
Output of get-member

TIL, the vCenter object is handled a folder!
So, if you want to assign a tag to the vCenter get the datacenters folder and it works like a charm…

Get-Folder "Datacenters" | New-TagAssignment (Get-Tag -name $TagName -Category $TagCategory)