VMware Cloud Community
CBaum
Contributor
Contributor

Any way to show all VMs that have a tag with a specific category?

I can't seem to get my head around this, and maybe I'm missing something very obvious.  I am tagging all VMs with a costcenter of which there are dozens of per vcenter.  However the tag category for all of them is called 'showback'.  I want to use powercli to give me all VMs with a tag category of showback, so I can see which VMs are tagged and which aren't.  Any way to do this?

0 Kudos
1 Reply
VMwareGuy007
Contributor
Contributor

There is probably a more efficient way, but this was a quick one-liner that should work.

Get-vm | where { ($_ | Get-TagAssignment -Category 'Showback') } | foreach { $_.name, ($_ | Get-TagAssignment -Category 'Showback').tag.Name, '' }

That will get the VM with the tag from the 'Showback' category, and then list the VM, name, the tag assignment from that category, and then a space, so it's not all cluttered.

0 Kudos