I recently had to audit a vSphere environment and identify all VMs using RDM disks.
One quick method is using RVTools—just export the data, go to the vDisk sheet, and filter the RAW column for True
.
If you’d like to cross-check that list or prefer an automated approach, here’s a PowerCLI script I used to validate the results.
The PowerCLI Script:
This script connects to a vCenter, scans all ESXi hosts in a specified cluster, and exports a list of consumed RDM (Raw Device Mapping) disks attached to VMs into a CSV file.
# Connect to vCenter
$vCenter = "vCenter FQDN"
Connect-VIServer $vCenter
# Get Cluster Name
$clusterName = "Cluster Name"
$cluster = Get-Cluster -Name $clusterName
if (-not $cluster) {
Write-Host "Cluster '$clusterName' not found! Exiting..." -ForegroundColor Red
Disconnect-VIServer -Confirm:$false
exit
}
# Get all ESXi hosts in the cluster
$hosts = Get-VMHost -Location $cluster
# Prepare result array for consumed RDMs
$rdmList = @()
# Loop through each host
foreach ($esxi in $hosts) {
Write-Host "Processing host: $($esxi.Name)..."
# Get all VMs on the host
$vms = Get-VM -Location $esxi
# Loop through each VM and check for RDMs
foreach ($vm in $vms) {
$rdms = Get-HardDisk -VM $vm -DiskType RawPhysical, RawVirtual
foreach ($rdm in $rdms) {
$rdmList += [PSCustomObject]@{
VMName = $vm.Name
ESXiHost = $esxi.Name
RDMFile = $rdm.Filename
RDMType = $rdm.DiskType
CapacityGB = $rdm.CapacityGB
DeviceName = $rdm.ScsiCanonicalName
}
}
}
}
# Output consumed RDMs
Write-Host "`n==== Consumed RDM Mappings for Cluster: $clusterName ===="
$rdmList | Format-Table -AutoSize
# Export only the consumed RDM list
$rdmList | Export-Csv ".\$clusterName-RDM_List.csv" -NoTypeInformation
Write-Host "`nExported consumed RDM list to: $clusterName-RDM_List.csv"
# Disconnect from vCenter
Disconnect-VIServer -Confirm:$false
To run the script across all vSphere clusters, replace the lines in the first part of the script with the following:
# Connect to vCenter
$vCenter = "vCenter FQDN"
Connect-VIServer $vCenter
# Get all ESXi hosts in the cluster
$hosts = Get-VMHost
# Prepare result array for consumed RDMs
...
Feel free to customize this script based on your specific reporting requirements and share your experiences or improvements in the comments below.
It should be noted that the script is not entirely authored by me; certain information and code snippets are sourced from various places, including blogs, GitHub repositories, and community forums.