VMware Cloud Community
enwilson01
Contributor
Contributor

Speed up query of Get-ScsiLunPath

Hi LUCD and all,

currently I am run the following script to check the scsilunPath for vmware farm.

Everything work fine with all field that I need.

However I would like to improve the response of the script. currently it run around 22mins to get 6100 record.

May I ask if anyway to speed it up by using get-view or some others function to get similar results. Thanks in advance.

My powercli version: 12.2.0

 

$filepath = "C:\report"
$filename = "report.csv"
$pathStateActive = 0
$pathStateDead = 0
$pathStateStandby = 0
$Clusterlist = Get-Cluster -location "Production Datacenter"
$report= @()
ForEach ( $clustername in $Clusterlist ) {
$esxName = Get-Cluster -name $clustername| Get-VMHost
ForEach ( $esx in $esxName ) {
$esxcli = Get-EsxCli -VMHost $esx
$devices = $esx | Get-ScsiLun -PipelineVariable lun
foreach ($naa in $devices) {
$pathState = $naa | Get-ScsiLunPath | Group-Object -Property state
$pathStateActive = $pathState | ? { $_.Name -eq "Active"}
$pathStateDead = $pathState | ? { $_.Name -eq "Dead"}
$pathStateStandby = $pathState | ? { $_.Name -eq "Standby"}
$row = "" | Select Cluster, ESXihost, NAA, Active, Dead, Standby
$row.Cluster = $clustername.name
$row.ESXihost = $esx.name
$row.NAA = $naa.CanonicalName
$row.Active = $pathStateActive.Count
$row.Dead = $pathStateDead.Count
$row.Standby = $pathStateStandby.Count
$report += $row
}
}
}
$report | Export-Csv $filepath\$filename.csv -NoTypeInformation -UseCulture

 

0 Kudos
3 Replies
LucD
Leadership
Leadership

enwilson01
Contributor
Contributor

May I know where I can get the NAA ID or the Canonical Name from the get-view 

Thanks

0 Kudos
LucD
Leadership
Leadership

Have a look at Re: Export ESXi Storage Device paths in excel - VMware Technology Network VMTN
in that code I retrieve that info as well.


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