Import-Module dataontap #Change This #Connect-NcController -Name -Vserver $luntable = Get-NcLun | Select-Object Path -ExpandProperty Path function get-luninfo { param( [string]$lunpath ) if (get-nclunmap $lunpath) { $lunid = Get-NcLunmap $lunpath | Select-Object LunId -ExpandProperty LunId $lunigroup = get-nclunmap $lunpath | Select-Object InitiatorGroup -ExpandProperty InitiatorGroup $vserver = Get-NcLun $lunpath | Select-Object Vserver -ExpandProperty Vserver $lunigrouptype = Get-NcIgroup -Name $lunigroup | Select-Object InitiatorGroupType -ExpandProperty InitiatorGroupType $lunigrouptypeOS = Get-NcIgroup -Name $lunigroup | Select-Object InitiatorGroupOsType -ExpandProperty InitiatorGroupOsType $lunigroupAluaEna = Get-NcIgroup -Name $lunigroup | Select-Object InitiatorGroupAluaEnabled -ExpandProperty InitiatorGroupAluaEnabled $initiators = Get-NcIgroup -Name $lunigroup | Select-Object Initiators -Unique -ExpandProperty Initiators $initiatorstatus = @() foreach ($in in $initiators.Initiators.InitiatorName) { $status = Confirm-NcLunInitiatorLoggedIn -VserverContext $vserver -Initiator $in | Select-Object Value -ExpandProperty Value $initiatorstatus += @(@{Initiator="$in";Online="$status"}) } foreach ($object in $initiatorstatus) { $initiatoronline += $object.ForEach({[PSCustomObject]$_}) } $obj = New-Object -TypeName PSObject $obj | add-member -MemberType NoteProperty -Name "vServer" -Value $vserver $obj | add-member -MemberType NoteProperty -Name "Lun ID" -Value $lunid $obj | add-member -MemberType NoteProperty -Name "IGROUP Name" -Value $lunigroup $obj | add-member -MemberType NoteProperty -Name "IGROUP TYPE" -Value $lunigrouptype $obj | add-member -MemberType NoteProperty -Name "IGROUP TYPE OS" -Value $lunigrouptypeOS $obj | add-member -MemberType NoteProperty -Name "IGROUP ALUA ENABLE" -Value $lunigroupAluaEna $obj | add-member -MemberType NoteProperty -Name "Lun Path" -Value $lunpath #$obj | add-member -MemberType NoteProperty -Name "Initiator Info" -Value $initiatoronline Write-Output $obj | FT Write-Output $initiatoronline } else { $vserver = Get-NcLun $lunpath | Select-Object Vserver -ExpandProperty Vserver $obj = New-Object -TypeName PSObject $obj | add-member -MemberType NoteProperty -Name "vServer" -Value $vserver $obj | add-member -MemberType NoteProperty -Name "Lun Path" -Value $lunpath $obj | add-member -MemberType NoteProperty -Name "Lun Mapping" -Value "Lun Not Mapped" Write-Output $obj | FT -Wrap -AutoSize } } #Calling the Function foreach ($lun in $luntable) { get-luninfo($lun) }