You can use a script to generate tags automatically. For example, you can create a virtual machine owner tag for each user account in a domain.

You must use the Get-VIAccount cmdlet to retrieve user accounts. For more information, see the documentation of the cmdlet.

Verify that you are connected to a vCenter Server system.

Verify that the user accounts and the vCenter Server system are in the same domain.


Create a new tag category and specify that tags in this category can only be assigned to entities of type VirtualMachine.

$OwnerTagCategory = New-TagCategory -Name Owner -EntityType VirtualMachine

If you do not specify an entity type, tags from this category can be assigned to all entity types.


Retrieve all domain user accounts and save them in a variable.

$Accounts = Get-VIAccount -User -Domain 'DomainName' -Category | select -ExpandProperty Id

Create a tag for each user account.

$Accounts | foreach { New-Tag -Category $OwnerTagCategory -Name $_ }

Retrieve a specific tag from the Owner category, so that you can later assign it to a specific virtual machine.

$OwnerTag = Get-Tag -Category $OwnerTagCategory -Name 'John_Smith'