RDM disk finder – Powercli script

RDM disk finder – Powercli script

 

 

 

 

 

 

$vcenter = “Your vcenter name”

Connect-VIServer $vcenter

$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, VMHost, HDDeviceName, HDName, HDFileName, HDMode, HDsize, HDDisplayName, LUN

$row.VMName = $vm.Name

$esx = Get-View $vm.Runtime.Host

$row.VMHost = ($esx).Name

$row.HDDeviceName = $dev.Backing.DeviceName

$row.HDName = $dev.DeviceInfo.Label

$row.HDFileName = $dev.Backing.FileName

$row.HDMode = $dev.Backing.CompatibilityMode

$row.HDSize = [system.math]::Round($dev.CapacityInKB / 1048576)

$row.HDDisplayName = ($esx.Config.StorageDevice.ScsiLun | where {$_.Uuid -eq $dev.Backing.LunUuid}).CanonicalName

$lun = Get-ScsiLun -VmHost $row.VMHost -CanonicalName $row.HDDisplayName

$row.LUN = $lun.RuntimeName.SubString($lun.RuntimeName.LastIndexof(“L”)+1)

$report += $row

}

}

}

}

$report

 

 

 

Please Comment and Subscribe

Loading

Leave a Reply

Your email address will not be published. Required fields are marked *