Hi,
I am unable to get the output of all VMs which has RDM disk information in a single file from the below script
$vmview = Get-View -ViewType VirtualMachine
$DiskInfo = @()
foreach ($VirtualSCSIController in ($VMView.Config.Hardware.Device | where { $_.DeviceInfo.Label -match "SCSI Controller" }))
{
foreach ($VirtualDiskDevice in ($VMView.Config.Hardware.Device | where { $_.ControllerKey -eq $VirtualSCSIController.Key -and $_.Backing -is [VMware.Vim.VirtualDiskRawDiskMappingVer1BackingInfo] }))
{
$VirtualDisk = "" | Select VM_Host, VM, LUN, SCSI_Control, SCSI_ID, Capacity_GB, Disk_Name, Disk_File, Canonical_Name, Console_Name, Disk_Type, Vendor, Model #, Policy
$VirtualDisk.VM = $vmview.name
$esx = Get-View -Id $vmview.Runtime.Host
$VirtualDisk.VM_Host = ($esx).Name
$VirtualDisk.SCSI_Control = $VirtualSCSIController.DeviceInfo.Label
$VirtualDisk.Disk_Name = $VirtualDiskDevice.DeviceInfo.Label
$VirtualDisk.Disk_Type = $VirtualDiskDevice.backing
$VirtualDisk.SCSI_ID = $VirtualDiskDevice.UnitNumber
$VirtualDisk.Disk_File = $VirtualDiskDevice.Backing.FileName
$VirtualDisk.Capacity_GB = $VirtualDiskDevice.CapacityInKB * 1KB / 1GB
$VirtualDisk.Canonical_Name = ($esx.Config.StorageDevice.ScsiLun | where { $_.Uuid -eq $VirtualDiskDevice.Backing.LunUuid }).CanonicalName
$lun = Get-ScsiLun -VmHost ($esx).Name -CanonicalName $VirtualDisk.Canonical_Name
$VirtualDisk.LUN = $lun.RuntimeName.SubString($lun.RuntimeName.LastIndexof("L") + 1)
#$VirtualDisk.Console_Name = ($esx.Config.StorageDevice.ScsiLun | where { $_.Uuid -eq $VirtualDiskDevice.Backing.LunUuid }).DevicePath
$VirtualDisk.Console_Name = ($esx.Config.StorageDevice.ScsiLun | where { $_.Uuid -eq $VirtualDiskDevice.Backing.LunUuid }).DeviceName
$VirtualDisk.Vendor = ($esx.Config.StorageDevice.ScsiLun | where { $_.Uuid -eq $VirtualDiskDevice.Backing.LunUuid }).Vendor
$VirtualDisk.Model = ($esx.Config.StorageDevice.ScsiLun | where { $_.Uuid -eq $VirtualDiskDevice.Backing.LunUuid }).Model
$DiskInfo += $VirtualDisk
}
}
$DiskInfo | Export-Csv -Path $out_csvpath -Delimiter "," -NoTypeInformation
Error
Cannot find an overload for "SubString" and the argument count: "1".
At D:\All_Export_RDM_node.ps1:49 char:4
+ $VirtualDisk.LUN = $lun.RuntimeName.SubString($lun.RuntimeName.Las ...
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : NotSpecified: (:) [], MethodException
+ FullyQualifiedErrorId : MethodCountCouldNotFindBest