Automation

 View Only
  • 1.  Copy VM Tags From VMs

    Posted May 27, 2021 12:46 PM

    Is there a way to take the tags from <VM NAME> and copy them to <VM NAME>_replica?



  • 2.  RE: Copy VM Tags From VMs

    Posted May 27, 2021 12:57 PM

    Yes



  • 3.  RE: Copy VM Tags From VMs

    Posted May 27, 2021 12:58 PM

    lol any advice on how to conquer this? I am at a loss on how to do this today.



  • 4.  RE: Copy VM Tags From VMs

    Posted May 27, 2021 01:06 PM

    Use the TagAssignment cmdlets.
    Something like this for example.



  • 5.  RE: Copy VM Tags From VMs

    Posted May 27, 2021 02:48 PM

    That is simple, can I point this at all my VMs and somehow array through all them?



  • 6.  RE: Copy VM Tags From VMs

    Posted May 27, 2021 05:13 PM

    Sure, just leave out the Name parameter on the Get-VM



  • 7.  RE: Copy VM Tags From VMs

    Posted Jun 09, 2021 08:25 PM

    I am running this:

     

    $vmName = Get-VM

    $copyVm = "$($vmName)_replica"

    Get-VM -Name $vmName | Get-TagAssignment | ForEach-Object -Process { New-TagAssignment -Entity $copyVm -Tag $_.Tag }

     

    And when I get to the $copyVm = "$($vmName)_replica" part it combines all the VMs together in one line.  The next part then looks for a VM named everything.



  • 8.  RE: Copy VM Tags From VMs
    Best Answer

    Posted Jun 09, 2021 08:41 PM

    I meant like this