= Script: PowerCLI: VMs with RDM disks =
**Summary**: A script to collect RDM disk information from VMs \\
**Date**: Around 2013 \\
**Refactor**: 22 March 2025: Checked links and formatting. \\
{{tag>powershell vmware}}
This is a remake of a script found on http://www.virtu-al.net/2008/12/23/list-vms-with-rdm/ with the following changes:
* Added RDMs in virtualmode
* Added csv export
* Added the vmhost in the output
* Made some code readability changes
#Script Source: http://www.virtu-al.net/2008/12/23/list-vms-with-rdm/
#Connect-VIServer MYVISERVER
$timestamp = Get-Date -format "yyyyMMdd-HH.mm"
# $csvFile = Read-Host "Enter csv file"
$csvfile = "D:\sjoerd\$timestamp-rdmvms.csv"
$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, Host, HDDeviceName, HDFileName, Mode
$row.VMName = $vm.Name
$getvm = Get-VM $row.VMName
$row.Host = $getvm.VMHost
$row.HDDeviceName = $dev.Backing.DeviceName
$row.HDFileName = $dev.Backing.FileName
$row.Mode = $dev.Backing.CompatibilityMode
$report += $row
}
}
}
}
$report | export-csv -NoTypeInformation $csvfile
//This wiki has been made possible by://