VMware Cloud Community
praveensf
Contributor
Contributor

get esxi storage path details using powercli

ran the below script but getting an error saying "Get-ScsiLunPath        Value cannot be null" , any help would be appreciated!!

$results= @()
foreach ($VMHost in $VMHosts) {
[ARRAY]$HBAs = $VMHost | Get-VMHostHba -Type "FibreChannel"

    foreach ($HBA in $HBAs) {
    $scsiluns = Get-ScsiLun -Hba $HBA -LunType "disk"
    foreach ( $scsilun in $scsiluns) {
    $pathState = $scsilun | Get-ScsiLunPath | Group-Object -Property state
    $pathStateActive = $pathState | ? { $_.Name -eq "Active"}
    $pathStateDead = $pathState | ? { $_.Name -eq "Dead"}
    $pathStateStandby = $pathState | ? { $_.Name -eq "Standby"}
    $results += "{0},{1},{2},{3},{4},{5}" -f $VMHost.Name, $HBA.Device, $VMHost.Parent, [INT]$pathStateActive.Count, [INT]$pathStateDead.Count, [INT]$pathStateStandby.Count
    }
}
}

ConvertFrom-Csv -Header "VMHost","HBA","Cluster","Active","Dead","Standby" -InputObject $results | Ft -AutoSize

ERROR:


Get-ScsiLunPath : 12/2/2015 1:49:18 PM    Get-ScsiLunPath        Value cannot be null.
Parameter name: array   
At line:13 char:29
+     $pathState = $scsilun | Get-ScsiLunPath | Group-Object -Property state
+                             ~~~~~~~~~~~~~~~
    + CategoryInfo          : NotSpecified: (:) [Get-ScsiLunPath], VimException
    + FullyQualifiedErrorId : Core_BaseCmdlet_UnknownError,VMware.VimAutomation.ViCore.Cmdlets.Commands.Host.GetScsiLunPath

Reply
0 Kudos
16 Replies
LucD
Leadership
Leadership

Could it be that you one or more HBA that have no LUNs ?

You could test if $scsiluns -eq $null before you start the foreach loop


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

Reply
0 Kudos
praveensf
Contributor
Contributor

I'm pretty sure all the hba's have luns assigned to it in our environment. I did a ctrl+c while running the script and ran the following part manually.

Get-ScsiLun -Hba $HBA -LunType "disk"

CanonicalN ConsoleDeviceName              LunType         CapacityGB MultipathPolicy
ame                                                                                 
---------- -----------------              -------         ---------- ---------------
naa.514... /vmfs/devices/disks/naa.514... disk                20.000 Unknown        
naa.514... /vmfs/devices/disks/naa.514... disk               512.000 Unknown        
naa.514... /vmfs/devices/disks/naa.514... disk             8,192.000 Unknown        
naa.514... /vmfs/devices/disks/naa.514... disk             8,192.000 Unknown        
naa.514...                                disk                10.000 Unknown        
naa.514... /vmfs/devices/disks/naa.514... disk             8,192.000 Unknown        
naa.514... /vmfs/devices/disks/naa.514... disk             8,192.000 Unknown        
naa.514... /vmfs/devices/disks/naa.514... disk             8,192.000 Unknown        
naa.514... /vmfs/devices/disks/naa.514... disk             8,192.000 Unknown

Reply
0 Kudos
praveensf
Contributor
Contributor

BTW I'm running this script across multiple hosts and I'm getting the same error.

Reply
0 Kudos
praveensf
Contributor
Contributor

Please see below.............

Get-VMHost myhost.com | Get-ScsiLun | Get-ScsiLunPath


Get-ScsiLunPath : 12/2/2015 2:40:43 PM    Get-ScsiLunPath        Value cannot be null.
Parameter name: array   
At line:1 char:57
+ Get-VMHost myhost.com | Get-ScsiLun | Get-ScsiLunPath
+                                                         ~~~~~~~~~~~~~~~
    + CategoryInfo          : NotSpecified: (:) [Get-ScsiLunPath], VimException
    + FullyQualifiedErrorId : Core_BaseCmdlet_UnknownError,VMware.VimAutomation.ViCore.Cmdlets.Commands.Host.GetScsiLunPath

Get-VMHost myhost.com | Get-ScsiLun

CanonicalN ConsoleDeviceName              LunType         CapacityGB MultipathPolicy
ame                                                                                 
---------- -----------------              -------         ---------- ---------------
naa.514... /vmfs/devices/disks/naa.514... disk             8,192.000 Unknown        
naa.514... /vmfs/devices/disks/naa.514... disk                20.000 Unknown        
naa.514... /vmfs/devices/disks/naa.514... disk             8,192.000 Unknown        
naa.514... /vmfs/devices/disks/naa.514... disk               512.000 Unknown        
naa.514... /vmfs/devices/disks/naa.514... disk             8,192.000 Unknown        
naa.514... /vmfs/devices/disks/naa.514... disk             8,192.000 Unknown        
naa.514... /vmfs/devices/disks/naa.514... disk             8,192.000 Unknown        
naa.514... /vmfs/devices/disks/naa.514... disk             8,192.000 Unknown        

Reply
0 Kudos
LucD
Leadership
Leadership

Which PowerShell version are you using ?

Display the content of $PSVersionTable


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

Reply
0 Kudos
praveensf
Contributor
Contributor

Get-PowerCLIVersion

PowerCLI Version
----------------
   VMware vSphere PowerCLI 6.0 Release 1 build 2548067
---------------
Component Versions
---------------
   VMWare AutoDeploy PowerCLI Component 6.0 build 2358282
   VMWare ImageBuilder PowerCLI Component 6.0 build 2358282
   VMware License PowerCLI Component 6.0 build 2315846
   VMware vSphere PowerCLI Component 6.0 build 2548068

$PSVersionTable

Name                           Value                                                                                                                                                    
----                           -----                                                                                                                                                    
PSVersion                      4.0                                                                                                                                                      
WSManStackVersion              3.0                                                                                                                                                      
SerializationVersion           1.1.0.1                                                                                                                                                  
CLRVersion                     4.0.30319.34209                                                                                                                                          
BuildVersion                   6.3.9600.16406                                                                                                                                           
PSCompatibleVersions           {1.0, 2.0, 3.0, 4.0}                                                                                                                                     
PSRemotingProtocolVersion      2.2

Reply
0 Kudos
LucD
Leadership
Leadership

Can we try to find out for which specific LUN the error is triggered ?

Try something like this

Get-VMHost myhost.com | Get-ScsiLun | %{

    Write-Host "LUN $($_.CanonicalName)"

    Get-ScsiLunPath -ScsiLun $_

}


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

Reply
0 Kudos
praveensf
Contributor
Contributor

LUN naa.514f0c5abcc0006e

Get-ScsiLunPath : 12/2/2015 3:46:37 PM    Get-ScsiLunPath        Value cannot be null.

Parameter name: array   

At line:5 char:5

+     Get-ScsiLunPath -ScsiLun $_

+     ~~~~~~~~~~~~~~~~~~~~~~~~~~~

    + CategoryInfo          : NotSpecified: (:) [Get-ScsiLunPath], VimException

    + FullyQualifiedErrorId : Core_BaseCmdlet_UnknownError,VMware.VimAutomation.ViCore.Cmdlets.Commands.Host.GetScsiLunPath

LUN naa.514f0c5abcc0003e

Get-ScsiLunPath : 12/2/2015 3:46:37 PM    Get-ScsiLunPath        Value cannot be null.

Parameter name: array   

At line:5 char:5

+     Get-ScsiLunPath -ScsiLun $_

+     ~~~~~~~~~~~~~~~~~~~~~~~~~~~

    + CategoryInfo          : NotSpecified: (:) [Get-ScsiLunPath], VimException

    + FullyQualifiedErrorId : Core_BaseCmdlet_UnknownError,VMware.VimAutomation.ViCore.Cmdlets.Commands.Host.GetScsiLunPath

LUN naa.514f0c5abcc0006f

Get-ScsiLunPath : 12/2/2015 3:46:37 PM    Get-ScsiLunPath        Value cannot be null.

Parameter name: array   

At line:5 char:5

+     Get-ScsiLunPath -ScsiLun $_

+     ~~~~~~~~~~~~~~~~~~~~~~~~~~~

    + CategoryInfo          : NotSpecified: (:) [Get-ScsiLunPath], VimException

    + FullyQualifiedErrorId : Core_BaseCmdlet_UnknownError,VMware.VimAutomation.ViCore.Cmdlets.Commands.Host.GetScsiLunPath

LUN naa.514f0c5abcc00063

Get-ScsiLunPath : 12/2/2015 3:46:38 PM    Get-ScsiLunPath        Value cannot be null.

Parameter name: array   

At line:5 char:5

+     Get-ScsiLunPath -ScsiLun $_

+     ~~~~~~~~~~~~~~~~~~~~~~~~~~~

    + CategoryInfo          : NotSpecified: (:) [Get-ScsiLunPath], VimException

    + FullyQualifiedErrorId : Core_BaseCmdlet_UnknownError,VMware.VimAutomation.ViCore.Cmdlets.Commands.Host.GetScsiLunPath

LUN naa.514f0c5abcc0005a

Get-ScsiLunPath : 12/2/2015 3:46:38 PM    Get-ScsiLunPath        Value cannot be null.

Parameter name: array   

At line:5 char:5

+     Get-ScsiLunPath -ScsiLun $_

+     ~~~~~~~~~~~~~~~~~~~~~~~~~~~

    + CategoryInfo          : NotSpecified: (:) [Get-ScsiLunPath], VimException

    + FullyQualifiedErrorId : Core_BaseCmdlet_UnknownError,VMware.VimAutomation.ViCore.Cmdlets.Commands.Host.GetScsiLunPath

LUN naa.514f0c5abcc00059

Get-ScsiLunPath : 12/2/2015 3:46:38 PM    Get-ScsiLunPath        Value cannot be null.

Parameter name: array   

At line:5 char:5

+     Get-ScsiLunPath -ScsiLun $_

+     ~~~~~~~~~~~~~~~~~~~~~~~~~~~

    + CategoryInfo          : NotSpecified: (:) [Get-ScsiLunPath], VimException

    + FullyQualifiedErrorId : Core_BaseCmdlet_UnknownError,VMware.VimAutomation.ViCore.Cmdlets.Commands.Host.GetScsiLunPath

LUN naa.514f0c5abcc00058

Get-ScsiLunPath : 12/2/2015 3:46:38 PM    Get-ScsiLunPath        Value cannot be null.

Parameter name: array   

At line:5 char:5

+     Get-ScsiLunPath -ScsiLun $_

+     ~~~~~~~~~~~~~~~~~~~~~~~~~~~

    + CategoryInfo          : NotSpecified: (:) [Get-ScsiLunPath], VimException

    + FullyQualifiedErrorId : Core_BaseCmdlet_UnknownError,VMware.VimAutomation.ViCore.Cmdlets.Commands.Host.GetScsiLunPath

LUN naa.514f0c5abcc00057

Get-ScsiLunPath : 12/2/2015 3:46:38 PM    Get-ScsiLunPath        Value cannot be null.

Parameter name: array   

At line:5 char:5

+     Get-ScsiLunPath -ScsiLun $_

+     ~~~~~~~~~~~~~~~~~~~~~~~~~~~

    + CategoryInfo          : NotSpecified: (:) [Get-ScsiLunPath], VimException

    + FullyQualifiedErrorId : Core_BaseCmdlet_UnknownError,VMware.VimAutomation.ViCore.Cmdlets.Commands.Host.GetScsiLunPath

Reply
0 Kudos
LucD
Leadership
Leadership

Are you by any chance using EMC Powerpath ?

There have been issues reported with the Get-ScsiLunPath cmdlet in such environments


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

Reply
0 Kudos
praveensf
Contributor
Contributor

unfortunately we are using powerpath. Is there any other way to get the path details ?? We have 100's of esxi hosts so manually checking them would be a real pain. We have been having PSOD's due to these dead paths so need identify the hosts immediately.

Thank you so much for your help!!

Reply
0 Kudos
LucD
Leadership
Leadership

There is an alternative described in PowerCLI: Getting LUN paths when using EMC PowerPath/VE


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

Reply
0 Kudos
praveensf
Contributor
Contributor

I'm not able to modify it the way I want, basically I'm looking for output something like  hostname, hba, activepaths, standbypaths, deadpaths

$dsHt = Get-View -ViewType Datastore -Property "Info","Summary.Type" -Filter @{"Summary.Type"="VMFS"} |
Select @{N="DSName";E={$_.Info.Vmfs.Name}}, @{N="Capacity";E={[math]::round( ($_.Info.Vmfs.Capacity / 1024 / 1024), 0)}},
@{N="Extent";E={$_.Info.Vmfs.Extent[0].DiskName}}, @{N="VMFS Version";E={$_.Info.Vmfs.Version}} |
Group-Object "Extent" -AsHashTable -AsString

$results = @()
Get-View -ViewType HostSystem -SearchRoot (Get-Cluster ClusterPod8).id -Property Name, Config.StorageDevice | %{
   $thisHostName = $_.Name
   $_.Config.StorageDevice.PlugStoreTopology.path | ?{$_.Name -match 'naa'} | Group-Object LunNumber | Sort-object Name | %{
     try {
       $thisNaaId = ($_.Group[0].Name -split "naa.")[1]
       $results += New-Object psobject -Property @{
         HostName = $thisHostName
         LunNumber = $_.Name
         PathCount = $_.Count
         DSName = $dsHt["naa.$thisNaaId"][0].DSName
         Capacity = $dsHt["naa.$thisNaaId"][0].Capacity
         "VMFS Version" = $dsHt["naa.$thisNaaId"][0]."VMFS Version"
       }
     } catch {
       Write-Warning "Found something with $thisNaaId"
     }
   } # end this Lun
} # end this host

$results |Group-Object pathcount

Reply
0 Kudos
lorried82
Enthusiast
Enthusiast

Hi LucD - Looks like I am having the same issue due to using EMC PowerPath - Anyway to add in the details to the script for the State of the Path?

Thanks for any help!

$dsHt = Get-View -ViewType Datastore -Property "Info","Summary.Type" -Filter @{"Summary.Type"="VMFS"} |
Select @{N="DSName";E={$_.Info.Vmfs.Name}}, @{N="Capacity";E={[math]::round( ($_.Info.Vmfs.Capacity / 1024 / 1024), 0)}},
@{N="Extent";E={$_.Info.Vmfs.Extent[0].DiskName}}, @{N="VMFS Version";E={$_.Info.Vmfs.Version}} |
Group-Object "Extent" -AsHashTable -AsString

$results = @()
Get-View -ViewType HostSystem -SearchRoot (Get-Cluster ClusterPod8).id -Property Name, Config.StorageDevice | %{
  $thisHostName = $_.Name
  $_.Config.StorageDevice.PlugStoreTopology.path | ?{$_.Name -match 'naa'} | Group-Object LunNumber | Sort-object Name | %{
    try {
      $thisNaaId = ($_.Group[0].Name -split "naa.")[1]
      $results += New-Object psobject -Property @{
        HostName = $thisHostName
        LunNumber = $_.Name
        PathCount = $_.Count
        DSName = $dsHt["naa.$thisNaaId"][0].DSName
        Capacity = $dsHt["naa.$thisNaaId"][0].Capacity
        "VMFS Version" = $dsHt["naa.$thisNaaId"][0]."VMFS Version"
      }
    } catch {
      Write-Warning "Found something with $thisNaaId"
    }
  } # end this Lun
} # end this host

$results |Group-Object pathcount

Leave a Reply

Reply
0 Kudos
LucD
Leadership
Leadership

I'm afraid I don't have an environment with EMC PowerPath, so I can't experiment.

Perhaps give this a try PowerCLI: Getting LUN paths when using EMC PowerPath/VE


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

Reply
0 Kudos
lorried82
Enthusiast
Enthusiast

OK thanks - That was what I was using - however the output is not very useful.

Reply
0 Kudos
LucD
Leadership
Leadership

Oops, sorry about that.
Isn't there an EMC forum where you could ask?


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

Reply
0 Kudos