• Skip to primary navigation
  • Skip to main content
  • Skip to primary sidebar

Yellow Bricks

by Duncan Epping

  • Home
  • Unexplored Territory Podcast
  • HA Deepdive
  • ESXTOP
  • Stickers/Shirts
  • Privacy Policy
  • About
  • Show Search
Hide Search

Which VM is connected to an RDM?

Duncan Epping · Nov 3, 2008 ·

A friend of mine asked me if there was a way to find out which VM’s were connected to a certain RDM disk. I’ve been looking all over but couldn’t find a simple command to do this. So I ended up on the forums and found a powershell script which creates a list with all the necessary info one would like to have:

$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, HDDeviceName, HDFileName, HDMode
$row.VMName = $vm.Name
$row.HDDeviceName = $dev.Backing.DeviceName
$row.HDFileName = $dev.Backing.FileName
$row.HDMode = $dev.Backing.CompatibilityMode
$report += $row
}
}
}
}
$report

All credits for this great script go to LucD!

Related

Server ESX, esxi, Scripting, Storage

Reader Interactions

Comments

  1. Jason Boche says

    3 November, 2008 at 16:50

    Nice one. I’ve got to get that useful scripts repository started…

  2. William says

    4 November, 2008 at 04:47

    Hi Duncan,

    This was a task I had before which I could not figure out, but your posting made me think about the issue again. I also had posted on the VMTN forums (http://communities.vmware.com/message/1090685) asking for a method and I had not realized that there was a way. Taking the idea and your posting, I came up with a quick/dirty script that can be ran on both ESX 3.5+ and ESXi to capture this same data set. You can find the shell script at:

    http://www.engr.ucsb.edu/~duonglt/rdm/

    I’m always open to more options since this one would require a Windows system and having powershell installed. This would allow users to run on their standard and beloved Service Console or ESXi (which requires SSH Console to be opened up). I’m also looking for a way to accomplish this on VIMA, since it’s the “centralize” management utility that VMware is pushing for, but the commands are pretty slow and still need to spend more time looking into the available command sets.

    -W

Primary Sidebar

About the Author

Duncan Epping is a Chief Technologist and Distinguished Engineering Architect at Broadcom. Besides writing on Yellow-Bricks, Duncan is the co-author of the vSAN Deep Dive and the vSphere Clustering Deep Dive book series. Duncan is also the host of the Unexplored Territory Podcast.

Follow Us

  • X
  • Spotify
  • RSS Feed
  • LinkedIn

Recommended Book(s)

Advertisements




Copyright Yellow-Bricks.com © 2025 · Log in