PowerCLI – List VMs with RDM


In today’s we will look at how to list VMs with RDM using PowerCLI. The idea behind the article came to my mind when I was working with one of the users.

The customer wanted to perform a SAN to SAN migration and there were a lot of Virtual Machines with RDMs configured.

I first performed a Google search and could find a few scripts available but most of them were lengthy and cumbersome.

I was looking at probably a one-liner which would list the Virtual Machine name along with the RDM details.

The one-liner that I wrote will list the below details:

  • Virtual Machine Name.
  • Hard Disk Name.
  • Disk Type (Physical or Virtual compatibility).
  • LUN ID of the device.
  • VML ID of the device.
  • VMDK File name.
  • The size of the RDM LUN.

Before you run this command, kindly connect to the vCenter Server or the ESXi host using the Connect-VIServer cmdlet.

Get-VM | Get-HardDisk | Where-Object {$_.DiskType -like “Raw*”} | Select @{N=”VMName”;E={$_.Parent}},Name,DiskType,@{N=”LUN_ID”;E={$_.ScsiCanonicalName}},@{N=”VML_ID”;E={$_.DeviceName}},Filename,CapacityGB | Export-Csv C:\Users\Adil\Desktop\RDM-list.csv -NoTypeInformation

The output of the CSV file will look something like below.

PowerCLI - List VMs with RDM

I hope this has informative and thank you for reading!


About Author

I am Adil Arif, working as a Senior Technical Support Engineer at Rubrik as well as an independent blogger and founder of Enterprise Daddy. In my current role, I am supporting infrastructure related to Windows and VMware datacenters.


  1. Thanks a lot for this! I’ve been trying to also add on which host the virtual machine resides but to no avail ( I have a cluster setup). would it be possible to help out please?

  2. Hello Adil,

    Thanks for great script.
    Mean while could you please help where I can add “$_.Parent.VMHost.Name” Is it possible you to give the script with adding this .

    • Hello Govind,
      The updated script would be as below.
      Get-VM | Get-HardDisk | Where-Object {$_.DiskType -like “Raw*”} | Select @{N=”VMName”;E={$_.Parent}},@{N=”ESXi Host”;E={$_.Parent.VMHost.Name}},Name,DiskType,@{N=”LUN_ID”;E={$_.ScsiCanonicalName}},@{N=”VML_ID”;E={$_.DeviceName}},Filename,CapacityGB | Export-Csv C:\Users\Adil\Desktop\RDM-list.csv -NoTypeInformation

  3. Hi Adil,

    thanks for that great post.

    I try to display additional the LUN-Number (not the LUN-ID). But i can´t find the correct parameter.
    Is this possible?

  4. I wish to learn the VMware PowerCLI. Do we have any link or article where I can refer and start learning from basics. Please help me.

Leave A Reply