Replace Bios.UUID after clone (copy uuid to clone)

This post was originally published on this site

Good evening,

we do run a test lab with some bigip appliances. As we play around with them and usually mess them up i wanted to create a clone to have a full backup of a clean appliance.

i figured out when i copy the bios.uuid i will not loose the activated license and so i do not need to bother the vendor again and again.

 

I am stuck in my scheduled task with the replacement. The tasks run shutdown the vm and take the clone.

I have to run these actions in jobs don’t ask me why. I could figure out why the “pure” commands do not work.

 

So here is the piece where i am stuck… And i would love if someone could enlighten me to get this to run.

I tagged the machines so the bios.uuid will not get replaced on other machines. Having the vendor details of the vm would be much cooler and i might open another post about this.

 

So i get the uuid from the master vm

# Get BIOS UUID

$uuid = Get-VM $vmname | %{(Get-View $_.Id).config.uuid}

And geht the Tag of the vm

# Get Tag of Virtual Machine (if assigned)

$tag = Get-VM $vmname | Get-TagAssignment | select Tag

 

$vmname is the master

$firstbackupname is the name of the clone

 

And here is the code which should replace the uuid on the vm ($firstbackupname)

 

if ($tag -match “F5”) {

                       LogWrite “”

                       LogWrite “Task Backup – F5 Tag assigned. Changing UUID”

                       Start-Job -ScriptBlock {

                                                $spec = New-Object VMware.Vim.VirtualMachineConfigSpec

                                                $spec.uuid = $uuid

                                                $firstbackupname.Extensiondata.ReconfigVM_Task($spec)

                                               }

                       Get-Job | Wait-Job

                       LogWrite “-OK—————–> Changed UUID to $uuid”

                      }

 

The scenario does shutdon the vm, wait for shutdown then take a clone and now it should copy the master uuid to the clone. Right after the vm gets a power on.

 

I would be very happy if you coudl help me out here.

thank you very much for any tip and help.

 

best wishes armin

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.