amakki
Contributor
Contributor

Script to get NAA and LUN ID

Hello,

Can I have a script to get NAA and LUN ID for all datastores in specific cluster or host or VM I tried to run some scripts to get runtime name but always getting an empty field, any Idea?

0 Kudos
5 Replies
dtaliafe
Hot Shot
Hot Shot

There are some additional datastore functions available to download in this blog post.

Automating Datastore/Storage Device Detachment in vSphere 5 - VMware vSphere Blog

Try "Get-DatastoreMountInfo".  It should get the LUN information.

0 Kudos
sayhi2vigneshba
Contributor
Contributor

Try to use RVTools, you can fetch the NAA and LUN ID for all datastores in specific cluster or host or VM

0 Kudos
amakki
Contributor
Contributor

Thanks for your hint, but RVtools does not return the LUN ID or NAA of specific VM only in host you can find NAA but not LUN ID also is not showing RDM LUNs as well.

0 Kudos
amakki
Contributor
Contributor

Thanks but I am still not able to see the LUN ID , the command get-scsilun have the option to export runtime where LUN ID is part of it however, it is always return empty information !!

0 Kudos
NavalgundRaj
Enthusiast
Enthusiast

Hi amakki..

Once you run this and export to .csv

$esxName = "bdesx03.dev.ops"

Connect-VIServer vcnp02.dev.ops

New-VIProperty -Name lunDatastoreName -ObjectType ScsiLun -Value {

    param($lun)

    $ds = $lun.VMHost.ExtensionData.Datastore | %{Get-View $_} | `

        where {$_.Summary.Type -eq "VMFS" -and

            ($_.Info.Vmfs.Extent | where {$_.DiskName -eq $lun.CanonicalName})}

    if($ds){

        $ds.Name

    }

} -Force | Out-Null

Get-VMHost -Name $esxName | Get-ScsiLun | Select CanonicalName, CapacityMB, lunDatastoreName

Note: If you found this correct or answer useful please consider the use of the Correct buttons to award points. Regards Basavaraj.R Navalgund
0 Kudos