Search
  • khushnood khan

Matching windows disk drive with VMware vm's disk.

This is a very common issue in which IT admins struggle in finding the related disk from VMware vm to that of windows vm.

In this post I will go through the concept of finding the disk with PowerShell command.


I have created a vm and it is having 8 disks.

vm name : testvm1

Hard disks:


We can see the hard disk are on 2 different controllers and the buss sequence is different for the hard disks.


From within the windows vm we can see the below hard disks.

The disk no in windows and that of VMware would not match and can't be taken for comparison.

Lot of admins also take the hard disk size as a reference to find the disk to that of VMware.

That might work for some cases but not always .This might fail when 2 disk size have the same size.

We have to find a different approach for it.

We can match the hard disk and the vmware through controller and buss id.

We can see the controller and buss id for the hard disk in the vm on the edit menu as shown in the very first screenshot.

Now the question is how to get the same in windows.


To get the buss id and controller id below script would be a great help.

This is a power shell script and it was run on the vm which is in question.



script:

$SCSItgid=get-wmiobject win32_diskdrive| select serialnumber,scsitargetid

$scsiloc=@()

$report=@()

foreach ($scsitdid1 in $SCSItgid)

{

$scsiloc =get-disk| where SerialNumber -eq $scsitdid1.serialnumber

$report += new-object psobject -property @{

serialnumber=$scsiloc.serialnumber

harddiskno= $scsiloc.number

totalsize =[math]::Round($scsiloc.size/1GB,0)

Scsicontroller=$scsiloc.location

Scsibus=$scsitdid1.scsitargetid

}

}

$report


The out put of the script would be below.





From the output we can see the serial no, scsibus , scsicontroller and harddisk no of the vm.

now we can compare the scsi bus and controller to that of the vmware.


Another way of comparison is the disk uuid.

The disk uuid for windows is the serial number as shown above screenshot.

Now we need to get the disk uuid of the vm hard disk from vmware.

below is the script for the same.


Powercli script:

connect-viserver <serverip/fqdn>

$vmname="testvm1"

$vmharddisk1= get-vm -name $vmname| get-harddisk

$vmreport=@()

Foreach ($vmharddisk in $vmharddisk1)

{

$vmreport += new-object psobject -property @{

uuid=$vmharddisk.ExtensionData.Backing.Uuid|ForEach-Object {$_.replace('-','')}

harddiskname= $vmharddisk.name

totalsize = $vmharddisk.capacityGB

}

}

$vmreport




We can compare the two uuid to get the hard disks compared.


284 views0 comments

Recent Posts

See All