VMware Cloud Community
GuilhermeAlves
Enthusiast
Enthusiast
Jump to solution

Get-ScsiLun/Get-SCSiLunPath Faster


Is there a way to make the above script faster?

I know that is a problem with Get-scsiLun and Get-ScsiLunPath. They are very lazy when querying againsta too much hosts or too much paths..

I wanna know if there is a way to get this info using get-view or something...


$esxs = Get-Vmhost
$esx = $esxs[1]

$multipathInfos=@()
#Get information about Multipath
$multipathInfos += $esx | Get-ScsiLun -LunType disk  |%{
    $VMHostScsiLun=$_
        $VMHostScsiLunPaths = $VMHostScsiLun | Get-ScsiLunPath
        $VMHostScsiLunPaths | Select @{N="Hostname"; E={$esx.Name}}, @{N="Number of Paths"; E={($VMHostScsiLunPaths|measure).count}}, Sanid, ScsiCanonicalName, State,@{N="Policy"; E={$VMHostScsiLun.MultipathPolicy}}
}$multipathInfos

0 Kudos
1 Solution

Accepted Solutions
LucD
Leadership
Leadership
Jump to solution

Everything is Poshible  :smileygrin:

Try something like this

$esxName = "MyEsx"

$esx = Get-View -ViewType HostSystem -Property Name,Config.StorageDevice -Filter @{"Name"="^$esxName"}
foreach($lun in $esx.Config.StorageDevice.MultipathInfo.Lun){
 
$scsiLun = $esx.Config.StorageDevice.ScsiLun |
   
where{$_.Key -eq $lun.Lun}

 
$lun.Path | Select @{N="Hostname";E={$esx.Name}},
   
@{N="Number of Paths";E={$lun.Path.Count}},
   
@{N="SanId";E={("{0:x}" -f $lun.Path[0].Transport.NodeWorldWideName) -replace '(..(?!$))','$1:'}},
   
@{N="ScsiCanonicalName";E={$scsiLun.CanonicalName}},
   
@{N="State";E={$_.State}},
   
@{N="Policy";E={
     
if($lun.Policy.Policy -match "_FIXED"){"Fixed"}
     
elseif($lun.Policy.Policy -match "_MRU"){"MostRecentlyUsed"}
     
elseif($lun.Policy.Policy -match "_RR"){"RoundRobin"}
     
else{"Unknown"}}}
}
 


Blog: lucd.info  Twitter: @LucD22  Co-author PowerCLI Reference

View solution in original post

0 Kudos
2 Replies
LucD
Leadership
Leadership
Jump to solution

Everything is Poshible  :smileygrin:

Try something like this

$esxName = "MyEsx"

$esx = Get-View -ViewType HostSystem -Property Name,Config.StorageDevice -Filter @{"Name"="^$esxName"}
foreach($lun in $esx.Config.StorageDevice.MultipathInfo.Lun){
 
$scsiLun = $esx.Config.StorageDevice.ScsiLun |
   
where{$_.Key -eq $lun.Lun}

 
$lun.Path | Select @{N="Hostname";E={$esx.Name}},
   
@{N="Number of Paths";E={$lun.Path.Count}},
   
@{N="SanId";E={("{0:x}" -f $lun.Path[0].Transport.NodeWorldWideName) -replace '(..(?!$))','$1:'}},
   
@{N="ScsiCanonicalName";E={$scsiLun.CanonicalName}},
   
@{N="State";E={$_.State}},
   
@{N="Policy";E={
     
if($lun.Policy.Policy -match "_FIXED"){"Fixed"}
     
elseif($lun.Policy.Policy -match "_MRU"){"MostRecentlyUsed"}
     
elseif($lun.Policy.Policy -match "_RR"){"RoundRobin"}
     
else{"Unknown"}}}
}
 


Blog: lucd.info  Twitter: @LucD22  Co-author PowerCLI Reference

0 Kudos
GuilhermeAlves
Enthusiast
Enthusiast
Jump to solution

Do i need to thank again? hehehe :smileylaugh:

You're the best Luc!

This script is part of another i've did here => https://communities.vmware.com/docs/DOC-26302

Initially i was using RVTools to export some information...and i'm still exploring the Steve Jin's VI Java API

Until I get good on it, i'll try to get faster responses with PowerShell/Cli. It Never lets me down! Smiley Wink

0 Kudos