- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
You can use a hash table to lookup datastorenames via the canonicalname.
Something like this
$report = @()
$dsTab = @{}
foreach($ds in (Get-Datastore | where{$_.ExtensionData.Summary.MultipleHostAccess})){
$ds.ExtensionData.Info.Vmfs.Extent | %{
if($_.DiskName){
$dsTab.Add($_.DiskName,$ds.Name)
}
}
}
foreach ($clusterName in Get-Cluster) {
$report += Get-Cluster -Name $clusterName | Get-VMHost | %{
$esxcli = Get-EsxCli -VMHost $_
$esxcli.storage.core.device.list() |
Select @{N='ESX';E={$esxcli.VMHost.Name}},Device,
@{N='lunID'; E={
$d = $_
if(([Version]$esxcli.VMHost.Version).Major -lt 6){
$lun = Get-ScsiLun -VmHost $esxcli.VMhost | Where {$_.CanonicalName -eq $d.Device}
$runtime = $lun.RuntimeName
}
else{
$lun = $esxcli.VMHost.ExtensionData.Config.StorageDevice.ScsiLun | Where-Object{$_.CanonicalName -eq $d.Device}
$lunUuid = $lun.Uuid
$runtime = ($esxcli.VMHost.ExtensionData.Config.StorageDevice.MultipathInfo.Lun | Where-Object{$_.Id -eq $lunUuid}).Path[0].Name
}
$runtime.Split('L')[1]
}},
@{N='Datastore';E={$dsTab[$_.Device]}}
}
}
$report
But note that this will only cover datastores, not RDMs.
Perhaps you could have a look at my LUN Report – Datastore, RDM And Node Visibility post?
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference