5 Replies Latest reply on May 16, 2018 11:05 PM by ifany

    Syncronize "tags" between vcenter servers

    vCJ Novice

      Maybe someone already have a solution for this, so I will ask here before I pull all my hair out.

       

      In one of our vcenter we started using tags a while back. Looks like that is the way we want to go, so now the challenge is how to "sync" tags between all our vcenter servers.

      Hopefully some of you already have a way of doing this, or some idea on where to start.

       

      I guess we could export using csv and import to an other vcenter? Or is there a better way?

      All suggestions are very welcome at this stage..

       

      Best Regards

      Jorgen S

        • 1. Re: Syncronize "tags" between vcenter servers
          LucD Guru
          Community WarriorsvExpertUser Moderators

          What exactly do you want to sync ?

          The tag categories, the tag assignments....?

          If it's tag assignments, how does that work with entities. Are the same entities present ion both vCenters ?

          • 2. Re: Syncronize "tags" between vcenter servers
            vCJ Novice

            Hi LucD

             

            I basically just wanna copy/paste all the categories and tags, not the assignments

            That way we have the same tag "library" in all vcenters.

            I just dont want to manually insert all the categories and tags in all my vcenters.

             

            Create in "master" vcenter --> copy to all other vcenter servers.

            - No, vm relations that will be set in the individual vcenter when new vm's get deployed.

            I just need the tags and the tag categories to be there when someone deploy a new vm and then they can assign the right tag for their vm.

            • 3. Re: Syncronize "tags" between vcenter servers
              LucD Guru
              vExpertCommunity WarriorsUser Moderators

              You could use a CSV file to export/import categories and tags.

              Something like this.

              Note that depending on the number of connections you have open, you would need to use the Server parameter to indicate where to export/import.

               

              1) Export

               

              &{foreach($tCat in Get-TagCategory){

                  $tags = Get-Tag -Category $tCat

                  if($tags){

                      $tags | Select @{N='Category';E={$tCat.Name}},@{N='cDescription';E={$tCat.Description}},@{N='Cardinality';E={$tCat.Cardinality}},Name,Description

                  }

                  else{

                      $tCat | Select @{N='Category';E={$tCat.Name}},@{N='cDescription';E={$tCat.Description}},@{N='Cardinality';E={$tCat.Cardinality}},@{N='Name';E={''}},@{N='Description';E={''}}

                  }

              }} | Export-Csv C:\tag.csv -NoTypeInformation -UseCulture

               

              2) Import

               

              foreach($tag in Import-Csv c:\tag.csv -UseCulture){

                  Try{

                      Get-TagCategory -Name $tag.Category -ErrorAction Stop

                  }

                  Catch{

                      New-TagCategory -Name $tag.Category -Description $tag.cDescription -Cardinality $tag.Cardinality -Confirm:$false

                  }

                  if($tag.Name){

                      Try{

                          Get-Tag -Category $tag.Category -Name $tag.Name -ErrorAction Stop

                      }

                      Catch{

                          New-Tag -Name $tag.Name -Category $tag.Category -Description $tag.Description -Confirm:$false

                      }

                  }

              }

              • 4. Re: Syncronize "tags" between vcenter servers
                vCJ Novice

                This was just perfect LucD, thank you so much.

                • 5. Re: Syncronize "tags" between vcenter servers
                  ifany Lurker

                  This works on 6.5 just ran it today.