List VM’s with RDM
I was asked if it was possible to list all VM’s with Raw Disk Mappings on twitter, a quick search of the VI Toolkit community showed that LucD had already achieved this, I have copied the code below for reference:
Connect-VIServer MYVISERVER $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"){ $row = "" | select VMName, HDDeviceName, HDFileName $row.VMName = $vm.Name $row.HDDeviceName = $dev.Backing.DeviceName $row.HDFileName = $dev.Backing.FileName $report += $row } } }}$report
Powershell V2 CTP3 Removing SCVMM from vCenter











Here is another solution that does not require PS:
http://www.engr.ucsb.edu/~duonglt/vmware
search for rdm.sh
Thanks William, that’s usefull
I suggest one adjustment. This is not inclusive of virtual compatability mode RDMs. Changing:
if($dev.Backing.CompatibilityMode -eq “physicalMode”){
to
if(($dev.Backing.CompatibilityMode -eq “physicalMode”) -or ($dev.Backing.CompatibilityMode -eq “virtualMode”)){
will fill that gap
Hrm. Maybe there is some ignorance here on my part (wouldn’t be the first time!) but this is erroring out for me.
Unexpected token ‘vms’ in expression or statement.
At line:1 char:18
+ $report = @()$vms <<<< = Get-VM | Get-View
+ CategoryInfo : ParserError: (vms:String) [], ParentContainsErro
rRecordException
+ FullyQualifiedErrorId : UnexpectedToken
vCenter 4.1, vSphere 4.0
Any suggestions would be greatly appreciated.
Hi,
thanks for the script. I made a few small changes because I got the same error as Jay. It needed an ENTER inside that line. I also added the vmhost and the virtualmode disks as suggested by ccalvin. I posted it on my own site:
http://www.warmetal.nl/powerclirdmvms
of which I hope you’re ok with Alan?
Of course, great to see improvements!
I got your script to find ” list the VMs with RDM”. However I need to know how many RDMs are connected to each VM?
I am running into Lun limitation and wants to see where all my luns got consumed?