Quantcast
Channel: VMware Communities : All Content - All Communities
Viewing all articles
Browse latest Browse all 175326

Tag multiple VM's

$
0
0

Hi,

I'm trying to tag multiple VM's in a large environment (thousands).

I'm hoping that I can read the contents of a csv and use PowerCLI to do the Tagging

 

cvs format would be

MyServer1,ApplicationNameXxxx

MyServer1,ApplicationNameBbbb

 

What I have so far is

 

$tc = New-TagCategory -Name "Application Name"
Get-Content -Path c:\VMTags.csv | ConvertFrom-Csv -Header VMname,Tag | foreach {
    if (!(Get-Tag -Name $_.tag)) {
        $t = $tc | New-Tag $_.tag
    }

    Get-VM -Name $_.VMname | New-TagAssignment -Tag $t -Confirm:$false
}

 

My intention is

  1. PowerCLI reads the csv file
  2. If the specified Tag does not exist already, it is created and assigned to the "Application Name" tag category
  3. The tag is then assigned to the VM

 

Thanks


Viewing all articles
Browse latest Browse all 175326

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>