Late last year i wrote about identifying chain linked VM’s within the vCloud environment, since then ive had to export a number of virtual machines from vCloud back to native vSphere.
For some of the process we need to use the ManagedBy.PS1 powershell script provided by VMware in this artice (its attached) https://kb.vmware.com/s/article/2032366
The script that i wrote to do this is below
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 | # Export VM script for vCloud (required ManagedBy Script from VMware) # Variables for the vApp Decommission. $disablespec = New-Object VMware.Vim.VirtualMachineConfigSpec $disablespec.vAppConfigRemoved = $True # Text file with list of VM's we want to export from vCloud $vms = Get-Content "vms.txt" Foreach ($vm in $vms) { $vm = "$vm" Write-Host "Cleaning UUID UP :" $vm #Remove vCloud UUID settings in vmx configuration Get-AdvancedSetting -entity "$vm" -Name cloud.uuid|Remove-AdvancedSetting Write-Host "Unlinking VM from vCloud Management :" $vm # Unlink managed by Invoke-Expression -Command '.\ManagedBy.ps1 -Cmd Clear -VMs $vm' Write-Host "Removing vApp Flag :" $vm #Remove vApp Flag $vm = Get-VM $vm | Get-View $vm.ReconfigVM($disablespec) } |
This successfully cleans up the VM removing the UUID in advanced settings are un-linking it from vcloud, it also changes the VM from a vApp to a standard VM. What you will be left with is the same VM with a (UUID reference number after it). Should you wish to remove this UUID referance number you can do afterwards with the script below, however check your backup technology before hand as it may see the changes as a new system and remove your historical references.
1 2 3 4 5 6 7 8 9 10 11 | # Same text file that was used for the vCloud Export $vms = Get-Content "vms.txt" Foreach ($vm in $vms) { $vm = "$vm" Write-Host "Current VM Name :" $vm $newvm = $vm.Substring(0, $vm.IndexOf('(')) Write-Host "New VM Name :" $newvm Set-VM -VM $vm -Name $newvm } |
And that should be it.
Recent Comments