Hi
Looking for a bit of help with a script I have. This script works with esxi 5.5 but not 6.5. Can anyone help me with why the Lun_ID is not showing in 6.5.
$report = @()
$VMs = @("")
Foreach ($VM in $VMs){
$LUN = ""
$VmView = Get-View -ViewType VirtualMachine -Filter @{"Name" = $VM}
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})) {
if(($VirtualDiskDevice.Backing.CompatibilityMode -eq "physicalMode") -or ($VirtualDiskDevice.Backing.CompatibilityMode -eq "virtualMode"))
{
$VMinfo = Get-VM $VM
$LUN = Get-Scsilun ($VMinfo | Get-Harddisk -Name ($VirtualDiskDevice.DeviceInfo.Label)).ScsiCanonicalName -VmHost ($VMinfo).VMHost
$line = "" | Select 'VMName', 'VMHost', 'HDDeviceName', 'HDName', 'HDFileName', 'HDMode', 'HDSize(GB)','LUN_ID', 'CanonicalName', 'SCSI_ID'
$line.'VMName' = $VMinfo.name
$line.'VMHost' = get-view $vmview.runtime.host | select -ExpandProperty name
$line.'HDDeviceName' = $VirtualDiskDevice.Backing.DeviceName
$line.'HDName' = $VirtualDiskDevice.DeviceInfo.Label
$line.'HDFileName' = $VirtualDiskDevice.Backing.FileName
$line.'HDMode' = $VirtualDiskDevice.Backing.CompatibilityMode
$line.'HDSize(GB)' = ($VirtualDiskDevice.CapacityInKB * 1KB / 1GB)
$line.'LUN_ID' = $LUN.RuntimeName.Substring($LUN.RuntimeName.LastIndexOf("L")+1)
$line.'CanonicalName' = ($VMinfo | Get-Harddisk -Name ($VirtualDiskDevice.DeviceInfo.Label)).ScsiCanonicalName
$line.'SCSI_ID' = "$($VirtualSCSIController.BusNumber) : $($VirtualDiskDevice.UnitNumber)"
$Report += $line
}
}
}
}
$report
Many Thanks
Mikey
The latest (11.3.0), will give you all bug fixes, performance improvements and new features.
Note that the later versions are installed from the PowerShell Gallery with Install-Module.
See Welcome PowerCLI to the PowerShell Gallery – Install Process Updates for details.
---------------------------------------------------------------------------------------------------------------------------
Was it helpful? Let us know by completing this short survey here.
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference
Which PowerCLI version are you using?
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference
I am using 5.8 Release 1.
That's a very old version.
Any reason why you are still on that version?
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference
No reason, just never upgraded it. what version would you recommend?
The latest (11.3.0), will give you all bug fixes, performance improvements and new features.
Note that the later versions are installed from the PowerShell Gallery with Install-Module.
See Welcome PowerCLI to the PowerShell Gallery – Install Process Updates for details.
---------------------------------------------------------------------------------------------------------------------------
Was it helpful? Let us know by completing this short survey here.
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference
Hi LucD
Many Thanks
Updating my PowerCLI has solved my issue.