listing SCSI Address or Virtual Disk Device with VM's Hard Disk number, Scsi Canonical Name and device

This post was originally published on this site

Hi, points for someone who can get the info from these two scripts to report in one command:

 

$vm=”VMname”

$vmview = Get-View -ViewType VirtualMachine -Filter @{“Name” = $vm}

 

 

foreach ($VirtualSCSIController in ($vmview.Config.Hardware.Device | where {$_.DeviceInfo.Label -match “SCSI Controller”})) {

foreach ($VirtualDiskDevice in ($vmview.Config.Hardware.Device | where {$_.ControllerKey -eq $VirtualSCSIController.Key})) {

Write-Host SCSI” (“$($VirtualSCSIController.BusNumber):$($VirtualDiskDevice.UnitNumber)”)” $VirtualDiskDevice.DeviceInfo.Label

 

}

}

 

This gives

 

SCSI (1:8) Hard disk 23

SCSI (1:9) Hard disk 24

SCSI (1:10) Hard disk 25

SCSI (1:12) Hard disk 26

SCSI (1:11) Hard disk 27

SCSI (1:13) Hard disk 28

SCSI (1:14) Hard disk 29

SCSI (1:15) Hard disk 30

 

which I found here:  http://www.virten.net/2015/08/match-linux-scsi-devices-sdx-to-virtual-disks-in-vmware/

 

and from VMware:

 

https://kb.vmware.com/selfservice/microsites/search.do?language=en_US&cmd=displayKC&externalId=2001823

 

get-VM VMName | Get-HardDisk -DiskType “RawPhysical

“,”RawVirtual” | Select Parent,Name,DiskType,ScsiCanonicalName,DeviceName | fl >

List-VMName-RDMs.txt

 

which gives:

 

Parent            : VMName

Name              : Hard disk 29

DiskType          : RawPhysical

ScsiCanonicalName : naa.514f0c5411400124

DeviceName        : vml.02001f0000514f0c5411400124587472656d41

 

 

Parent            : VMName

Name              : Hard disk 30

DiskType          : RawPhysical

ScsiCanonicalName : naa.514f0c5411400125

DeviceName        : vml.0200200000514f0c5411400125587472656d41

 

 

Parent            : VMName

Name              : Hard disk 31

DiskType          : RawPhysical

ScsiCanonicalName : naa.514f0c5411400126

DeviceName        : vml.0200210000514f0c5411400126587472656d41

 

again, points for help in giving the script that will give both the info from this last script with the SCSI ID and hard disk count together.

 

cheers

KC