You can assign a tag to a group of virtual machines. For example, you can assign a custom tag to all virtual machines that belong to a specific department in your organization.

Verify that you are connected to a vCenter Server system.

1

Get the virtual machines of a department in your organization.

$vms = Get-VM sales-dpt*
2

Assign the custom tag to the group of virtual machines.

$vms | New-TagAssignment -Tag $salesDptTag