VMware Cloud Community
gjbrown
Enthusiast
Enthusiast

apply tags in bulk

Hi all,

I am trying to apply tags in bulk.

I have a txt file with all my vm names and I want to apply the same tag to all of them. I tried a simple command like below (taking the text file out of the mix for now), and my powercli just sits blinking for days.

Can someone help me with the correct syntax to amek the below work and actually use a text file for input of vm names?

Get-VM –Name *jsmith* | New-TagAssignment –Tag “jsmith”

fyi using vcenter 6.5u latest

and powerclie 6.5r1

Thank you,

GB

Reply
0 Kudos
1 Reply
jrodsguitar
Enthusiast
Enthusiast

Your syntax is correct. The issue is that you must use the FQDN of the server when you connect to it.

There are multiple things that do not work if you don't use the FQDN so I make it a habit to always use the FQDN when connecting.

So use Connect-VIServer -server FQDN.

Connect-VIServer -server FQDN

New-TagCategory 'testCategory'

New-Tag -Name 'testTag' -Category 'testCategory' -Description 'testDescription'

Get-VM 'testVM' | New-TagAssignment -Tag 'testTag'

Blog: https://powershell.house/