- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
That info is available and can be stored in a couple of hash tables.
Something like this for example.
Note that this needs to be expanded (the $pathTab hash table), when a LUN has multiple paths.
Now the script only takes the first available path
$esxName = 'MyEsx'
$esx = Get-VMHost -Name $esxName
$adapterTab = @{}
$esx.ExtensionData.Config.StorageDevice.HostBusAdapter | %{
$adapterTab.Add($_.Key,$_.Device)
}
$pathTab = @{}
$esx.ExtensionData.Config.StorageDevice.MultipathInfo.Lun | %{
$pathTab.Add($_.Lun,$_.Path[0].Name)
}
$lunTab = @{}
$esx.ExtensionData.Config.StorageDevice.ScsiLun | %{
$lunTab.Add($_.Key,$_.CanonicalName)
}
foreach($adapter in $esx.ExtensionData.Config.StorageDevice.ScsiTopology.Adapter){
foreach($target in $adapter.Target){
foreach($lun in $target.Lun){
$lun | Select @{N='Adapter';E={$adapterTab[$adapter.Adapter]}},
@{N='Canonical';E={$lunTab[$lun.ScsiLun]}},
@{N='Path';E={$pathTab[$lun.ScsiLun]}},
Lun
}
}
}
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference