VMware Cloud Community
chiaramontef
Contributor
Contributor

Script to get All .NAA devices presented to a cluster

I'm having difficulty creating/finding a script to accomplish what I need. 

I'm trying to pull all of the .naa id's that are presented to a specific cluster in my 6.0 environment.  We are using powerpath, so getting this information with Get-ScsiLun command returns me and error like the one below. We have many devices (datastores/LUN's/RDM's) that are presented to various clusters in our environment and not all of them are added as VMFS storage devices or RDM's.  Some are recoverpoint targets that will be scanned and added as a datastore during an SRM failover, but are still presented and zoned to the cluster and we've had issues ensuring that all of these devices are present and ready for failover. 

So essentially, I need a script that can take an input (get-content) which will contain list of .naa identifiers (targets) and I want to reference that against the cluster and get a report on which hosts, if any, see those ID's. 

As an alternative, just getting a list to generate against the cluster that will properly export all of the .naa identifiers which I can export to excel and then use excel filters and lookup's against my targets would be sufficient.

Any help would be greatly appreciated!

Get-ScsiLun : 2/25/2018 12:02:30 PM    Get-ScsiLun        Value cannot be null.

Parameter name: array

At D:\scripts\frank\storage\test4.ps1:6 char:11

+           Get-ScsiLun -Hba $hba | %{

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

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

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

Thanks,

Frank

0 Kudos
1 Reply
chiaramontef
Contributor
Contributor

So far, I've been able to make some progress with this.  This is what I've been able to piece together.  It accurately lists all of my devices presented to the cluster regardless of powerpath, etc.  Any tips on how to add some intelligence to it so that I can import a list (get-content) of device id's and only report on the servers that cannot see those ID's would be a big help.

$MaxLUNPaths  = 2

$myHosts = Get-VMHost | where {$_.ConnectionState  -eq "Connected" -and $_.PowerState -eq "PoweredOn"}

$Report = @()

foreach ($myHost in $myHosts) {

$esxcli2 = Get-ESXCLI -VMHost $myHost -V2

$devices = $esxcli2.storage.core.path.list.invoke() | select Device -Unique

foreach ($device in $devices) {

$arguments = $esxcli2.storage.core.path.list.CreateArgs()

$arguments.device = $device.Device

$LUNs = $esxcli2.storage.core.path.list.Invoke($arguments)

$LUNReport = [PSCustomObject] @{

HostName = $myHost.Name

Device = $device.Device

LUNPaths = $LUNs.Length

LUNIDs = $LUNs.LUN | Select-Object -Unique

}

$Report += $LUNReport

}

}

$Report | where {$_.LUNPaths -gt $MaxLUNPaths -or ($_.LUNIDs | measure).count -gt 1 }  | ft -AutoSize

$table += $Report

$table | Export-Csv c:\temp\hba.csv -NotypeInformation -UseCulture

Thanks,

Frank

0 Kudos