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
I have found a way for this and it worked for me so far.
Go to Disk Management > Disk X > Properties > General > Location
Here, Location 160 is SCSI Controller 0 and Target ID is the location inside the controller.
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
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