SCRIPT SYNOPSIS / REASON CREATED – At the time of this script, we have over 800 VMs across multiple datacenters. In a few of those DCs, we have a small number of VMs that have RDMs attached (for use with Microsoft Clustering). Our current environment is VMware 5.5 hosts, so we still are VERY careful when doing anything (vMotion, etc.) on these VMs with RDMs. Per the article at https://blogs.vmware.com/apps/2015/02/say-hello-vmotion-compatible-shared-disks-windows-clustering-vsphere.html this will be a non-issue for us when we get all hosts upgraded to vSphere 6.
OVERVIEW OF STEPS – This is a very simple script that connects to your vCenter with the supplied credentials and then gets all VMs in the environment, specifically looking for VMs with a disk type of “RawPhysical” or “RawVirtual.” Once the script identifies VMs with these types of disks, it outputs the Parent (VM) Name, Disk File Type, and SCSI Canonical Name. There is an additional line of code that is currently remarked out that can output the results to a CSV file if desired.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 |
<# Script to Determine which VMs have RDMs attached Created by Shannon Fitzpatrick, 12.07.15 Website: www.shanfitz.com Twitter: @shanfitz Last Modified Date: 12.07.15 Modifications Made: Initial Script Creation #> # Variables $user = "administrator@vsphere.local" $pass = "Password" $vcenter = "vcenter.name" # Connect to vCenter connect-viserver $vcenter -user $user -password $pass # Display VMs in environment with attached RDMs Get-VM | Get-HardDisk -DiskType "RawPhysical","RawVirtual" | Select Parent,Name,DiskType,Filename,ScsiCanonicalName # Unremark the below command if you want to export data to a CSV file # Get-VM | Get-HardDisk -DiskType "RawPhysical","RawVirtual" | Select Parent,Name,DiskType,Filename,ScsiCanonicalName | Export-csv c:\output\rdmdisks.csv # Disconnect vCenter disconnect-viserver * -confirm:$false |