Contributor
Contributor

Match correctly windows disk to vmware harddisk

I've been searching all over for a way I could match disks inside windows to vmware's harddisk

The problem is when I have disks with same scsi id on more than one scsicontroller (for ex. (1:0)  and (0:0))

I found some scripts that compare the scsicontroller.bus number with the windows scsiport -1 but its not always the case..sometimes its -2 and sometimes its equal with no change. Any ideas? thanks in advance

25 Replies
Contributor
Contributor

  I’m still waiting for a reaction.

0 Kudos
Contributor
Contributor

I have found a way for this and it worked for me so far.

Go to Disk Management > Disk X > Properties > General > Location

pastedImage_0.pngpastedImage_1.png

Here, Location 160 is SCSI Controller 0 and Target ID is the location inside the controller.

pastedImage_2.png

This means SCSI(0:0) is Location 160 (Target ID 0)

SCSI(0:1) is Location 160 (Target ID 0)

SCSI(0:15) is Location 160 (Target ID 15)

SCSI(1:5) is Location 192 (Target ID 5) and so on

Contributor
Contributor

I came across the same question as everyone reading this post and I found FMON script the most useful for my purpose: query vm hard disks using a windows drive letter. I reused his code to write a PS module that integrates with existing VMWare cmdlets to ease resizing VM disks.

I have attached the module. You can simply extract it to C:\Windows\System32\WindowsPowerShell\v1.0\Modules or any other path in $env:PSModulePath. It exports a cmdlet called Get-VMHardDiskFromDriveLetter

After installing the module you can use it just like this:

Get-VM <vmname> | Get-VMHardDiskFromDriveLetter -DriveLetter D

The output will be the VM hard disk where this 😧 logical disk exists.

Because the cmdlet needs to access the guest OS, you must provide -Credential parameter that you can feed with a PS Credential if the currently logged in user doesn't have admin access to the Guest OS.

Get-VM <vmname> | Get-VMHardDiskFromDriveLetter -DriveLetter D -Credential (Get-Credential)

Then you can use the result and pipe it to the Set-HardDisk cmdlet to resize the disk where the partition exists.

Get-VM <vmname> | Get-VMHardDiskFromDriveLetter -DriveLetter D -Credential (Get-Credential) | Set-HardDisk -SizeGB 10

Thanks  FMON.

0 Kudos
Virtuoso
Virtuoso

Yes, until today 2018, there is no other way to consistently shows the result correctly.

/* Any kind of comment or input would be greatly appreciated */
0 Kudos
Enthusiast
Enthusiast

How does one use this DiskPart script? Where does the output go?

0 Kudos
Contributor
Contributor

saved my bacon on this one. i know im late to this party but ty

0 Kudos