PowerShell Script to list NetApp LUNs Mapped to Igroups

I wanted to get a list of which LUNs on my NetApp filer were mapped to each igroup. This script is not very efficient but it gets the job done in the format I wanted it in.

Using Windows PowerShell with the NetApp Data ONTap Module loaded and already connected to the filer I wanted to report against (using Connect-NaController) fist off I got a list of igroups and saved them into an array, i.e.

$igroups = Get-Naigroup

Then I created an object with the properties I wanted to collect using the following syntax

$output = “” | Select igroup, LUNid, Path

Then for each object in the $igroups array I had collected I ran Get-NaLUNbyigroup for each of the LUN ids 0 through to 255. I used the –ErrorAction:SilentlyContinue common parameter to hide the error messages for the LUN ids not mapped to the igroup. I collected the information I wanted in the $output object and then outputted the contents of this object. The commands looked like

Foreach ($igroup in $igroups) {

for ($lunid=0; $lunid -le 255; $lunid++) {

$output.igroup = $igroup.InitiatorGroupName

$output.LUNid = $lunid

$output.Path = get-nalunbyigroup $igroup.InitiatorGroupName $lunid -ErrorAction:SilentlyContinue




This entry was posted in NetApp, Powershell. Bookmark the permalink.

2 Responses to PowerShell Script to list NetApp LUNs Mapped to Igroups

  1. Michael Bietz says:

    Hi, i have optimized your Script. I hope you find it needfull.

    $naluns = Get-NaLun
    $output = “” | Select igroup, LUNid, Path

    Foreach ($nalun in $naluns)
    $lunmap = Get-NaLunMap $nalun
    $output.igroup = $lunmap.InitiatorGroupName
    $output.LUNid = $lunmap.LunId
    $output.Path = $lunmap.Path

  2. Abdul Wajid says:

    Here is a oneliner: 🙂
    Get-NaLun | Get-NaLunMap | select Name,LunID, Path | ft -AutoSize

Leave a Reply

Your email address will not be published. Required fields are marked *