VMware Cloud Community
Cinnistix
Contributor
Contributor

Tag Migration for VM's

We are currently doing a migration from VCSA-A to VCSA-B that are not ELM. We already exported and imported tags from VCSA-A to VCSA-B

Since its not ELM the tags are not the same UID and I cannot use the same source tag object to the target.

I am trying to do something like the following to get the tags re-applied after the migration:

 

Create Source VM variable

Collect source VM variable Tags

Collect Target VCSA variable tags

Compare Source VM tags to target VCSA tag list and create a variable for each target tag

Move VM

Create Target VM variable

Apply target tags to target VM from the compare above

 

Am I overthinking this?  It gets complicated due to the whole non-ELM issue.

 

0 Kudos
1 Reply
Cinnistix
Contributor
Contributor

I found a way to do it. This can be disregarded.

 

I didn't notice that Get-tagassignment and Get-tag have different parameters to get to the same "name"

 

For example to get to the tag name for get-tagassignment its (get-tagassignment).name

but with get-tag its (get-tag).tag.name

using these 2 commands I was able to run a where statement that gave me the right target tag.

 

 

foreach ($singleVMtag in $SourceVMTags){

$targetTag = $targetTags | where {$_.name -contains $singleVMtag.tag.name}

$singlevmdest | New-TagAssignment -Tag $targetTag

}

0 Kudos