I'm looking for a PowerCLI script that displays per cluster, per ESXi host how many active paths a datastore has.The output must look like:
Host Datastore Active Paths
ESXi01 VMFS-01 2
Thanks,
Ivo
Try this one, it show the actual count of the "active" paths per datastore.
foreach($esx in Get-VMHost){
$hss = Get-View $esx.Extensiondata.ConfigManager.StorageSystem
$lunTab = @{}
$hss.StorageDeviceInfo.ScsiLun | %{
$lunTab.Add($_.Key,$_.CanonicalName)
}
$pathTab = @{}
$hss.StorageDeviceInfo.MultipathInfo.Lun | %{
$pathState = @($_.Path | Group-Object -Property PathState |
where {$_.Name -eq "active"} | Select -ExpandProperty Group)
if($pathTab.ContainsKey($_.Lun)){
$pathTab[$_.Lun] += $pathState.Count
}
else{
$pathTab.Add($lunTab[$_.Lun],$pathState.Count)
}
}
foreach($mount in ($hss.FileSystemVolumeInfo.MountInfo | where {$_.Volume.Type -eq "VMFS"})){
$mount.Volume.Extent |
Select @{N="VMHost";E={$esx.Name}},
@{N="Datastore";E={$mount.Volume.Name}},
@{N="LUN";E={$_.DiskName}},
@{N="Active Paths";E={$pathTab[$_.DiskName]}}
}
}
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference
Hi,
Go with this.... Will help you in getting your requirement.
https://communities.vmware.com/message/1090993?tstart=0
Try this one, it show the actual count of the "active" paths per datastore.
foreach($esx in Get-VMHost){
$hss = Get-View $esx.Extensiondata.ConfigManager.StorageSystem
$lunTab = @{}
$hss.StorageDeviceInfo.ScsiLun | %{
$lunTab.Add($_.Key,$_.CanonicalName)
}
$pathTab = @{}
$hss.StorageDeviceInfo.MultipathInfo.Lun | %{
$pathState = @($_.Path | Group-Object -Property PathState |
where {$_.Name -eq "active"} | Select -ExpandProperty Group)
if($pathTab.ContainsKey($_.Lun)){
$pathTab[$_.Lun] += $pathState.Count
}
else{
$pathTab.Add($lunTab[$_.Lun],$pathState.Count)
}
}
foreach($mount in ($hss.FileSystemVolumeInfo.MountInfo | where {$_.Volume.Type -eq "VMFS"})){
$mount.Volume.Extent |
Select @{N="VMHost";E={$esx.Name}},
@{N="Datastore";E={$mount.Volume.Name}},
@{N="LUN";E={$_.DiskName}},
@{N="Active Paths";E={$pathTab[$_.DiskName]}}
}
}
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference
Thanks for the script Luc!