Hello:
Is there a way to extract LUNs info from ESX host? I need LUN(s) number/ID in order to match it with ID storage admin is seeing...
Thanks a lot!
Sure, simplest way is like this
$report = foreach($esx in Get-VMHost){ foreach($hbaKey in ($esx.Extensiondata.Config.StorageDevice.ScsiTopology.Adapter | where {$_.Adapter -like "*FibreChannelHba*"})){ if($hbaKey.Target){ foreach($tgtKey in $hbaKey.Target){ foreach($lunKey in $tgtKey.Lun){ $hba = $esx.Extensiondata.Config.StorageDevice.HostBusAdapter | where {$_.Key -eq $hbaKey.Adapter} $lun = $esx.Extensiondata.Config.StorageDevice.ScsiLun | where {$_.Key -eq $lunKey.ScsiLun} Select-Object -InputObject $lun -Property @{N="Host";E={$esx.Name}}, @{N="HBA";E={$hba.Device}}, CanonicalName,DisplayName,@{N="LUN";E={$lunKey.Lun}} } } } } } $report | Export-Csv "C:\lun-report.csv" -NoTypeInformation -UseCulture
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference
You can use the Get-ScsiLun cmdlet to extract LUN info from ESX hosts.
Regards, Robert
I think Get-SCSI LUN is very close, but I still do not see the LUN ID.
I run
Get-VMHost -Name "hostname" | Get-ScsiLun
and got the result:
Id : HostSystem-host-65635/vmhba1:1:1
CanonicalName : vmhba1:1:1
RuntimeName :
Key : key-vim.host.ScsiDisk-vmhba1:1:1
LunType : disk
Model : SYMMETRIX
SerialNumber : unavailable
Vendor : EMC
ConsoleDeviceName : /vmfs/devices/disks/vml.02000100006006048000019010420153303030393453594d4d4554
CapacityMB : 276210
MultipathPolicy : Fixed
CommandsToSwitchPath : 50
BlocksToSwitchPath : 2048
HostId : HostSystem-host-65635
VMHostId : HostSystem-host-65635
VMHost : ID = HostSystem-host-65635
Uid : /VIServer=email@hostname:443/VMHost=HostSystem-host-65635/ScsiLun=vmhba1:1:
1/
ExtensionData : VMware.Vim.HostScsiDisk
But here is still no info regarding LUN ID that I can see (match) on storage side.
How can I get just LUN ID info for all datastores on my hosts?
Thanks!
Best bet in cases like this is to google for s.th. like get-scsilun canonicalname lucd
Mabye this helps:
http://communities.vmware.com/thread/315049
André
What exactly do you mean with LUN ID ?
Do you see the value in the vSphere client ? Is it one of these ?
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference
Lol :smileylaugh:
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference
the issue is that this VC 2.5 with ESX 3.5...
refering to your picture, I am looking for Identifier (last 3 characters, like 09c, 279, 199, on your picture) and have to match it with Datastores names.
I run your script and for canonical name I have something like vmhba1:1:16, but not naa.60060160d2c82200f2addfa66c2cdf11 like I hoped to see.
Is it possible to get this info from 3.5 hosts?
Thanks a lot!
We can try, back to the old-fashioned way of doing this.
Try this
foreach($esx in Get-VMHost){ foreach($hbaKey in ($esx.Extensiondata.Config.StorageDevice.ScsiTopology.Adapter | where {$_.Adapter -like "*FibreChannelHba*"})){ if($hbaKey.Target){ foreach($tgtKey in $hbaKey.Target){ foreach($lunKey in $tgtKey.Lun){ $hba = $esx.Extensiondata.Config.StorageDevice.HostBusAdapter | where {$_.Key -eq $hbaKey.Adapter} $lun = $esx.Extensiondata.Config.StorageDevice.ScsiLun | where {$_.Key -eq $lunKey.ScsiLun} Select-Object -InputObject $lun -Property @{N="Host";E={$esx.Name}}, @{N="HBA";E={$hba.Device}}, CanonicalName,DisplayName,@{N="LUN";E={$lunKey.Lun}} } } } } }
Does it return the information you're after ?
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference
Wow this is cool LucD
thanks for sharing it here with us.
how to export it to CSV, where should I put the Export-CSV comamnd in ?
Sure, simplest way is like this
$report = foreach($esx in Get-VMHost){ foreach($hbaKey in ($esx.Extensiondata.Config.StorageDevice.ScsiTopology.Adapter | where {$_.Adapter -like "*FibreChannelHba*"})){ if($hbaKey.Target){ foreach($tgtKey in $hbaKey.Target){ foreach($lunKey in $tgtKey.Lun){ $hba = $esx.Extensiondata.Config.StorageDevice.HostBusAdapter | where {$_.Key -eq $hbaKey.Adapter} $lun = $esx.Extensiondata.Config.StorageDevice.ScsiLun | where {$_.Key -eq $lunKey.ScsiLun} Select-Object -InputObject $lun -Property @{N="Host";E={$esx.Name}}, @{N="HBA";E={$hba.Device}}, CanonicalName,DisplayName,@{N="LUN";E={$lunKey.Lun}} } } } } } $report | Export-Csv "C:\lun-report.csv" -NoTypeInformation -UseCulture
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference
Cool, many thanks for the reply Luc.
With your presence here the Powershell is now well known in IT wirld.
Luc,
Thanks a lot!