Change your VMware VM UUIDs to be Unique

UUID (Universally Unique IDentifier) are also known as GUIDs (Globally Unique IDentifier). A UUID is 128 bits long, and can guarantee uniqueness across space and time. Why do I care about UUIDs? Well VMware attempts to assign a unique UUID to every VM. Generally they succeed, but sometimes you can end up with VMs with duplicate UUIDs. UUIDs are present in physical hardware and also manifest themselves in Windows.

Recently I discovered this was happening for our VM templates, as we were using a unique method to transport and upload large templates to standalone ESX hosts before they were managed by vCenter. Basically we were using Veeam Backup to quickly restore templates to a host prior to shipping them to remote locations. What we didn’t realize was that all the templates would have the same UUID. Our backup software is now VMware aware and detected all of these duplicate UUIDs threw some errors. So I need a way to make sure our standalone VMs get built with unique UUIDs.

A VM’s .VMX file contains the UUID, and there are several methods to change it. First, you could just locate the BIOS.UUID value and change a few digits at random with Wordpad. This is fine, but prone to human error and not time efficient. So I cobbled together a little PowerShell script that attaches to an ESX host, enumerates all VMs, and tweaks the last eight digits in the UUID to make them all pseudo-unique.

All you need to do is run the PowerShell script via PowerCLI and give the IP address of the ESX host as an argument. A window will pop up asking for credentials, then it will enumerate all VMs and modify the UUID value. There’s nothing magical about the static portion of the UUID string in the script, so you can change that to a value from your environment if you wish.

The script pauses two seconds between each VM, so that the time stamp is unique for all VMs.


 # Usage: .changeUUID.ps1

if ($args[0].length -gt 0) {
connect-viserver $args[0]
$VMs = get-vm
foreach ($vm in $VMs){
$date = get-date -format “dd hh mm ss”
$newUuid = “56 4d 50 2e 9e df e5 e4-a7 f4 21 3b ” + $date
echo “VM: ” $VM.name “New UUID: ” $newuuid
$spec = New-Object VMware.Vim.VirtualMachineConfigSpec
$spec.uuid = $newUuid
$vm.Extensiondata.ReconfigVM_Task($spec)
start-sleep -s 2
}
}
else {Echo “Must supply IP address of ESX host. e.g. .changeUUID.ps1 192.168.0.10”}

So there you go, a way to easily change the UUID of your VMware virtual machines using PowerCLI.

Print Friendly, PDF & Email

Related Posts

Subscribe
Notify of
8 Comments
Oldest
Newest Most Voted
Inline Feedbacks
View all comments
June 2, 2011 1:05 pm

So if I do this to all of the vms in my environment, including lab manager vms cloned as linked clones templates and from library configurations, what are the ramifications? I can’t afford to hose the existing machines, which we use for our testing environment. The reason I want to make the change is that one of our products actually monitors vms and relies on unique uuid to do so.

Every environment is different, so testing is VERY wise. I have not seen any side effects of changing a VM’s UUID, except for making my backup software happier. But that’s not to say it couldn’t have adverse effects in your network. I would manually change the UUID on a few non-critical VMs watch them for a period of time, then if that’s OK, slowly change the others. I’d also recommend you back up the VMX files prior to the mods, so you can roll back the changes. Caution is in order!

April 16, 2012 3:59 pm

Hi, is there any way to access VM UUID within guest OS. In my case the guest OS will be Android running on top on VM.

Thanks.

April 16, 2012 7:12 pm

I don’t know…maybe one of my readers knows.

Anonymous
June 11, 2012 7:05 pm

Anonymous, no UUID has nothing to do with an AD SID. UUID is a “physical” property of the VM, unrelated to anything Windows specific.

Mike
September 9, 2014 1:56 pm

thanks a lot Derek. I ended up using something similar but I used Javascript and vCO to accomplish this. 1 question – why not generate a completely new GUID for each vm's bios UUID? Would you see a problem with doing that? I have done that and it seems to work okay for me. I blogged about my solution, for anyone needing to do this with vCO: http://michaelasaservice.com/?p=30