VMware Cloud Community
khanbashi
Contributor
Contributor

Extract Drive Letter with RDM

the below script to extract "VMName, VMHost, HDDeviceName, HDFileName, HDMode, HDsize, DiskLabel, SCSIBus, SCSIDevice, HDDisplayName " but i need to add also the drive letter  so can

someone help me .

$report = @()

$vms = Get-VM | Get-View

foreach($vm in $vms){

     foreach($dev in $vm.Config.Hardware.Device){

          if(($dev.gettype()).Name -eq "VirtualDisk"){

               if(($dev.Backing.CompatibilityMode -eq "physicalMode") -or

               ($dev.Backing.CompatibilityMode -eq "virtualMode")){

                    $row = "" | select VMName, VMHost, HDDeviceName, HDFileName, HDMode, HDsize, DiskLabel, SCSIBus, SCSIDevice, HDDisplayName

                    $row.VMName = $vm.Name

                    $esx = Get-View $vm.Runtime.Host

                    $row.VMHost = ($esx).Name

                    $row.HDDeviceName = $dev.Backing.DeviceName

                    $row.HDFileName = $dev.Backing.FileName

                    $row.HDMode = $dev.Backing.CompatibilityMode

                    $row.HDSize = $dev.CapacityInKB

                    $row.DiskLabel = $dev.DeviceInfo.Label

                    $row.SCSIBus = ( $vm.Config.Hardware.Device | ? { $_.Key -eq $dev.ControllerKey }).BusNumber

                    $row.SCSIDevice = $dev.UnitNumber

                    $row.HDDisplayName = ($esx.Config.StorageDevice.ScsiLun | where {$_.Uuid -eq $dev.Backing.LunUuid}).DisplayName

                    $report += $row

               }

          }

     }

}

$report | select VMName, VMHost, HDDeviceName, HDFileName, HDMode, HDsize, DiskLabel, SCSIBus, SCSIDevice, HDDisplayName |Export-Csv -Path "c:\RDMkMITC21-05-2014.csv"

0 Kudos
5 Replies
khanbashi
Contributor
Contributor

any update .....

0 Kudos
khanbashi
Contributor
Contributor

help please .

0 Kudos
khanbashi
Contributor
Contributor

Guys any help .....

0 Kudos
khanbashi
Contributor
Contributor

Guys any help .....

0 Kudos
khanbashi
Contributor
Contributor

Any help ...

0 Kudos