Basically I'm looking for the powershell equivalent of esxcfg-mpath -l.
Any help would be appreciated.
Try the attached script.
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference
Have you seen LucD's script here: http://communities.vmware.com/message/1105919;jsessionid=88763E29E3FBC6A1121772C3B8E0A6AE#1105919
If you found this information useful, please consider awarding points for Correct or Helpful.
Alan Renouf
Thanks Alan. Can you help me put the script together so it checks all hosts (not one at a time)?
Sure,
Foreach ($esx in (Get-VMHost | Get-View)){ Write $esx.Name foreach($disk in $esx.Config.StorageDevice.ScsiLun){ foreach($lun in $esx.Config.StorageDevice.MultipathInfo.Lun){ if($disk.CanonicalName -eq $lun.Id){ $pathNumber = $lun.Path.Count $policyName = $lun.Policy.Policy $capacityMb = ($disk.Capacity.Block * $disk.Capacity.BlockSize) / 1Mb # Disk line $line = "Disk " + $disk.CanonicalName + " (" + $capacityMb + "MB) has " + $pathNumber + " paths and policy of " + $policyName Write-Host $line # HBA line(s) $preferredPath = $lun.Policy.Prefer foreach($path in $lun.Path){ $device = $disk.CanonicalName.Substring(0,$disk.CanonicalName.IndexOf(":")) foreach($hba in $esx.Config.StorageDevice.HostBusAdapter){ if($hba.Device -eq $device){break} } if($path.Name -eq $preferredPath){$preferred = "preferred"} else{$preferred = ""} switch($path.PathState){ "active" {$pathStatus = "On active"} "disabled" {$pathStatus = "Off"} "standby" {$pathStatus = "On"} default {$pathStatus = "unknown"} } switch($path.Transport.gettype().Name){ "HostParallelScsiTargetTransport" { $line = " Local " + $hba.Pci + " " + $path.Name + " " + $pathStatus + " " + $preferred } "HostInternetScsiTargetTransport" { $line = " iScsi sw " + $hba.IScsiName + " <-> " + $path.Transport.IScsiName + " " + $pathStatus + " " + $preferred } } Write-Host $line } break } } } }
If you found this information useful, please consider awarding points for Correct or Helpful.
Alan Renouf
Try the attached script.
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference
Firstly, thanks LucD for putting all this information out here. Really great stuff. I wanted to understand better this portion of the script.
if($disk.CanonicalName -eq $lun.Id)
I am not sure how this is used. For example, when I output the canonicalname and the id (below). I am not seeing how they would show up as equal and thus be targeted by the rest of the script.
Many thanks.
C:\Program Files (x86)\VMware\Infrastructure\vSphere PowerCLI> $esx.config.storagedevice.scsilun | se
lect CanonicalName
CanonicalName
-
sym.018794010730313443
sym.018794010730313445
sym.018794010730313535
sym.018794010730313542
sym.018794010730313631
sym.018794010730303942
sym.018794010730303943
sym.018794010730303944
sym.018794010730303945
sym.018794010730313145
mpx.vmhba2:C0:T0:L0
C:\Program Files (x86)\VMware\Infrastructure\vSphere PowerCLI> $esx.config.storagedevice.multipathinf
o.lun | select id
Id
--
0100f0000039343031303731344330303053594d4d4554
010053000039343031303731344530303053594d4d4554
010054000039343031303731353530303053594d4d4554
010056000039343031303731354230303053594d4d4554
010055000039343031303731363130303053594d4d4554
010013000039343031303730394230303053594d4d4554
010016000039343031303730394330303053594d4d4554
010017000039343031303730394430303053594d4d4554
010019000039343031303730394530303053594d4d4554
01004f000039343031303731314530303053594d4d4554
0000000000766d686261323a303a30