Hi,
Sorry... I have searched and searched to try to get a script that listed all VM's RDM information and LUN number but nothing quite matched my requirement. I have hacked some code together which works but I am sure there must be a more efficient way to report this information (the script takes a very long time to complete)?
$result = @()
$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, Host, LUNID, HDLabel, HDFileName, Mode
if($dev.Backing.CompatibilityMode -eq "physicalMode"){
$row.Mode = "Physical RDM"
}
else {
$row.Mode = "Virtual RDM"
}
$row.HDFileName = $dev.Backing.FileName
$row.VMName = $vm.Name
$getvm = Get-VM $row.VMName
$row.Host = $getvm.VMHost
$row.HDLabel = $dev.DeviceInfo.Label
$Disk = Get-VM $row.VMName | Get-HardDisk | Where {$_.FileName -eq $row.HDFileName}
$Lun = Get-SCSILun $Disk.SCSICanonicalName -VMHost $row.Host
$row.LUNID = $Lun.RuntimeName.Substring($Lun.RuntimeName.LastIndexof(“L”)+1)
$result += $row
}
}
}
}
$result
Again, sorry if this does exist somewhere but if someone could point me to it, or amend this to be cleaner and quicker, it would be greatly appreciated.
Many thanks