VMware Cloud Community
RAMLOCK
Contributor
Contributor

How to find all UUID for VM

HI,

I want to login to esx console and find all UUIDs assigned to VMs. How can i do that?

thnx,

kaushik

0 Kudos
6 Replies
lamw
Community Manager
Community Manager

It depends on which UUID you're referring to, there are a few such as bios UUID or vCenter UUID for each VM?

You can easily retrieve these two from the Service Console with the following:

[root@himalaya ~]# grep -i uuid.bios /vmfs/volumes/4a31aece-e34d675a-72cf-003048d9586a/VIMA/VIMA.vmx
uuid.bios = "50 34 d5 e6 3a dd 63 86-7d 1e 01 44 95 96 f1 69"

[root@himalaya ~]# grep -i vc.uuid /vmfs/volumes/4a31aece-e34d675a-72cf-003048d9586a/VIMA/VIMA.vmx
vc.uuid = "5034638b-7aa2-3ca2-b07a-17fa3c4f5041"

Of course you can easily automate this through a simple for loop with the following snippet of code:

#!/bin/bash

for i in $(vmware-cmd -l);
do
        vmname=$(grep -i displayName ${i} | awk '{print $3}' | sed 's/"//g')
        vc_uuid=$(grep -i vc.uuid ${i} | awk -F "=" '{print $2}' | sed 's/"//g')
        bios_uuid=$(grep -i uuid.bios ${i} | awk -F "=" '{print $2}' | sed 's/"//g')
        echo -e "${vmname}\t${vc_uuid}\t${bios_uuid}"
done

and the output looks like the following:

dhcp-test        50 34 27 4a b3 62 f6 a9-dc d3 d7 4c 62 a2 41 e1         50 34 83 80 94 d6 17 0e-fa bd 46 4a 7d 68 00 d2
ThinStation-Dev  50 02 8a dd 13 71 a3 1d-eb f6 c7 03 8e bf be 52         56 4d 11 63 bc 02 7c a1-ab 26 15 58 ff 5d ff 69
NATbox   50 34 e8 48 4f d5 fc 62-f7 5f ae 8d fd ec d3 da         50 34 be 4c b3 e0 6c e9-09 28 7b cf 33 0f de 05
Thinapp  50 34 c5 6f 6b 6f c4 98-b8 58 41 c9 a4 11 c1 8b         50 34 a6 cc f5 7a e0 a1-70 9a 16 60 d2 7e 08 9a
hyper-clean      50 02 2c 7a 57 41 06 52-ee c1 03 e6 b3 ed 28 2d         42 02 5f e1 e8 84 1e 92-1a bb c3 16 17 4d 59 6a
scmom.6252009    50 02 12 46 0d 36 3c 88-bf ce 6c b6 d0 77 31 a6         42 02 54 93 c9 f3 06 9f-4b cd d1 a7 41 03 ff 41
hyper-dope       52 94 0c ac 16 13 3b 1a-da c8 c6 0e 9d 8e 7a c8         42 02 84 d9 54 05 0c 36-34 16 fe 3f a5 23 77 65
ESX-Kickstart    50 34 f1 64 57 1c 48 48-81 13 56 be 87 be a3 e7         50 34 8e 50 8c 33 a0 2b-72 fa 4f 31 a5 ad 35 68

=========================================================================

William Lam

VMware vExpert 2009

VMware ESX/ESXi scripts and resources at:

VMware Code Central - Scripts/Sample code for Developers and Administrators

If you find this information useful, please award points for "correct" or "helpful".

0 Kudos
RAMLOCK
Contributor
Contributor

I tried following as told but no output Smiley Sad

# grep -i vc.uuid *.vmx

# pwd

/vmfs/volumes/7.3IBM-FCP-DV/fcp-dv-vm4-suse

# ls

fcp-dv-vm4-suse_1-flat.vmdk fcp-dv-vm4-suse-flat.vmdk fcp-dv-vm4-suse.vmsd vmware-10.log vmware-13.log vmware.log

fcp-dv-vm4-suse_1.vmdk fcp-dv-vm4-suse.nvram fcp-dv-vm4-suse.vmx vmware-11.log vmware-14.log

fcp-dv-vm4-suse-f4ad2274.vswp fcp-dv-vm4-suse.vmdk fcp-dv-vm4-suse.vmxf vmware-12.log vmware-15.log

I am more interested to find the UUID of this VM.

As you can see all UUID of datastore can be availble directly from the pointed ID. Similarly i need the command to get UUID of all VMs in a perticular Datastore.

It is require for my script.

# ls -l

total 5132

drwxr-xr-x 1 root root 4096 Jul 7 04:14 3e6d7f65-2077c20a

drwxrwxrwt 1 root root 1400 Feb 10 05:33 476adf87-57213144-faa9-00145efda4fa

drwxr-xr-t 1 root root 2660 Jul 6 22:03 49c17932-0a6064b1-5fbf-00145efda4fc

drwxr-xr-t 1 root root 1260 Jun 2 20:22 4a166013-ebed2665-9469-00145efda4fc

drwxr-xr-t 1 root root 1260 Jul 6 22:17 4a2bd77f-308cc246-03c0-00145efda4fc

drwxr-xr-t 1 root root 1260 Jul 14 09:51 4a2ca556-3affa39b-e79a-00145efda4fc

drwxr-xr-x 1 root root 4096 Jul 12 22:25 5121dee3-b16eb4d2

drwxr-xr-x 1 root root 4096 Jul 7 04:15 6af39d1a-a9d5014f

lrwxr-xr-x 1 root root 17 Aug 4 00:08 732-2_NFS_DV_esx1 -> 5121dee3-b16eb4d2

lrwxr-xr-x 1 root root 35 Aug 4 00:08 7.3IBM-FCP-DV -> 49c17932-0a6064b1-5fbf-00145efda4fc

lrwxr-xr-x 1 root root 35 Aug 4 00:08 7.3IBM-FCP-DV-temp -> 4a2bd77f-308cc246-03c0-00145efda4fc

lrwxr-xr-x 1 root root 35 Aug 4 00:08 7.3IBM-FCP-DV-temp1 -> 4a166013-ebed2665-9469-00145efda4fc

lrwxr-xr-x 1 root root 35 Aug 4 00:08 7.3IBM-FCP-DV-temp3 -> 4a2ca556-3affa39b-e79a-00145efda4fc

lrwxr-xr-x 1 root root 35 Aug 4 00:08 local -> 476adf87-57213144-faa9-00145efda4fa

lrwxr-xr-x 1 root root 17 Aug 4 00:08 nfs_ds1 -> 6af39d1a-a9d5014f

lrwxr-xr-x 1 root root 17 Aug 4 00:08 nfs_ds2 -> 3e6d7f65-2077c20a

0 Kudos
lamw
Community Manager
Community Manager

Are you looking for the VM's UUID or the Datastore UUID? What you've shown me is the Datastore UUID which can be found for each VM by doing vmware-cmd -l and you'll get all the VMs + their Datastore UUID path.

=========================================================================

William Lam

VMware vExpert 2009

VMware ESX/ESXi scripts and resources at:

VMware Code Central - Scripts/Sample code for Developers and Administrators

If you find this information useful, please award points for "correct" or "helpful".

0 Kudos
RAMLOCK
Contributor
Contributor

I am looking for VM's UUID

0 Kudos
KellyOlivier
Enthusiast
Enthusiast

vm-support -x

0 Kudos
RAMLOCK
Contributor
Contributor

This are not UUID of VM's.

  1. vm-support -x

VMware ESX Server Support Script 1.30

Available worlds to debug:

vmid=1075 fcp-dv-vm1

vmid=1077 fcp-dv-vm10

vmid=1088 fcp-dv-vm11-x64

vmid=1091 fcp-dv-vm2-xp

vmid=1100 fcp-dv-vm3-rh

vmid=1103 fcp-dv-vm4-suse

vmid=1104 fcp-dv-vm5

vmid=1107 fcp-dv-vm6-xp

vmid=1118 fcp-dv-vm8-suse

vmid=1126 nfs-dv-vm03-xp

vmid=1132 nfs-dv-vm08-xp-x64

vmid=1133 nfs-dv-vm07-vista-x64

vmid=1139 fcp-dv-vm7-rh

vmid=1143 fcp-dv-vm9

vmid=1159 nfs-dv-vm05-suse

vmid=1164 nfs-dv-vm01

vmid=1168 nfs-dv-vm02-x64

vmid=1175 nfs-dv-vm04-rh

vmid=1176 test2

vmid=1197 nfs-dv-vm09-w2k8-x64

vmid=1204 nfs-dv-vm10-vista

vmid=1213 nfs-dv-vm06-w2k8

UUID of some of above mentioned VMs i am attaching with this mail. Need the same output from vmware console also. How can i get this.

0 Kudos