VMware Cloud Community
DanMan3395
Enthusiast
Enthusiast
Jump to solution

Compare vmdk UUID to Windows Disk UUID

In windows, a Get-Disk will produce a list of disks with serial numbers. In vMware, a (get-harddisk -vm $vmname).ExtensionData.Backing.Uuid will produce a list of vmdk UUIDs which match the serial numbers produced in windows.

I want to use this fact to correlate what disk in windows resides on what vmdk/vmware disk in vCenter. I would also like to correlate the windows volume name as well. However, i am struggling to get the logic to actually work.

Tags (2)
1 Solution

Accepted Solutions
LucD
Leadership
Leadership
Jump to solution

There are a couple of conditions for this to work.
This works for Windows 10 and 2016, when

  • VMware Tools are installed and running
  • the advanced setting 'disk.EnableUUID' needs to be set to TRUE (see KB52815)

Disclaimer 1: I only tested this with Windows 10 and Server 2016

Disclaimer 2: this only works for disks. There is afaik no fool-proof method to map guest OS partitions to VMDK

$vmName = 'MyVM'

$user = 'LucD'

$pswd = 'VMware1!'


$code = @'

Get-Disk | Select DiskNumber,SerialNumber | ConvertTo-Csv

'@


$vm = Get-VM -Name $vmName


if ($vm.Guest.State -ne 'Running')

{

   if ((Get-AdvancedSetting -Entity $vm -Name 'disk.EnableUUID').Value -eq 'true')

   {

    $diskTab = @{ }

    Invoke-VMScript -VM $vm -ScriptText $code -GuestUser $user -GuestPassword $pswd |

    select -ExpandProperty ScriptOutput | ConvertFrom-Csv |

    ForEach-Object -Process {

     $diskTab.Add($_.SerialNumber, $_.DiskNumber)

    }


   Get-HardDisk -VM $vm |

   Select @{N = 'VM'; E = { $_.Parent.Name } }, Name,

     @{N = 'Uuid'; E = { $_.ExtensionData.Backing.Uuid } },

     @{N = 'WinDisk'; E = { $diskTab[$_.ExtensionData.Backing.Uuid.Replace('-', '')] } }

   }

   else

   {

   Write-Host 'Serial number not showing (see KB52815)'

   }

}

else

{

   Write-Host "VMware Tools need to be installed and running"

}

---------------------------------------------------------------------------------------------------------

Was it helpful? Let us know by completing this short survey here.


Blog: lucd.info  Twitter: @LucD22  Co-author PowerCLI Reference

View solution in original post

2 Replies
LucD
Leadership
Leadership
Jump to solution

There are a couple of conditions for this to work.
This works for Windows 10 and 2016, when

  • VMware Tools are installed and running
  • the advanced setting 'disk.EnableUUID' needs to be set to TRUE (see KB52815)

Disclaimer 1: I only tested this with Windows 10 and Server 2016

Disclaimer 2: this only works for disks. There is afaik no fool-proof method to map guest OS partitions to VMDK

$vmName = 'MyVM'

$user = 'LucD'

$pswd = 'VMware1!'


$code = @'

Get-Disk | Select DiskNumber,SerialNumber | ConvertTo-Csv

'@


$vm = Get-VM -Name $vmName


if ($vm.Guest.State -ne 'Running')

{

   if ((Get-AdvancedSetting -Entity $vm -Name 'disk.EnableUUID').Value -eq 'true')

   {

    $diskTab = @{ }

    Invoke-VMScript -VM $vm -ScriptText $code -GuestUser $user -GuestPassword $pswd |

    select -ExpandProperty ScriptOutput | ConvertFrom-Csv |

    ForEach-Object -Process {

     $diskTab.Add($_.SerialNumber, $_.DiskNumber)

    }


   Get-HardDisk -VM $vm |

   Select @{N = 'VM'; E = { $_.Parent.Name } }, Name,

     @{N = 'Uuid'; E = { $_.ExtensionData.Backing.Uuid } },

     @{N = 'WinDisk'; E = { $diskTab[$_.ExtensionData.Backing.Uuid.Replace('-', '')] } }

   }

   else

   {

   Write-Host 'Serial number not showing (see KB52815)'

   }

}

else

{

   Write-Host "VMware Tools need to be installed and running"

}

---------------------------------------------------------------------------------------------------------

Was it helpful? Let us know by completing this short survey here.


Blog: lucd.info  Twitter: @LucD22  Co-author PowerCLI Reference

DanMan3395
Enthusiast
Enthusiast
Jump to solution

This is similar to what I was working on only much better. I to am thinking that a volume mapping just cannot be done. I cannot seem to find any kind of unique identifier to tie it into. Thanks LucD, as always, you were shockingly helpful!

0 Kudos