Automation

 View Only
  • 1.  Speed up query of Get-ScsiLunPath

    Posted Mar 24, 2023 01:12 AM

    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

     



  • 2.  RE: Speed up query of Get-ScsiLunPath

    Posted Mar 24, 2023 07:37 AM


  • 3.  RE: Speed up query of Get-ScsiLunPath

    Posted Mar 24, 2023 02:50 PM

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

    Thanks



  • 4.  RE: Speed up query of Get-ScsiLunPath

    Posted Mar 24, 2023 03:01 PM

    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.