The transition to NetApp MS Azure AD B2C is complete. If you missed the pre-registration, you will be invited to register at next log in.
Please note that access to your NetApp data may take up to 1 hour.
To learn more, read the FAQ and watch the video.
Need assistance? Complete this form and select “Registration Issue” as the Feedback Category.

Software Development Kit (SDK) and API Discussions

Powershell command/script to display lun name only (without full path)? (Get-NaLUN)


Our customer (running Ontap 9.7) has a need to obtain output that displays LUN names only, however when using the host utilities kit  (v7.1)they see that the output won't show just the LUN name, but instead includes the entire path to the LUN.


For Linux, we have a workaround for the 'sanlun lun show' command by using the following command to extract the LUN names:

sanlun lun show | grep vol | awk '{print $2}' | cut -d '/' -f 4


Trying to figure out a similar workaround for them for Windows, possibly using the Netapp Powershell toolkit and the 'Get-NaLUN' command. Anyone out there have thoughts on how to script this to make it viable?





Regex to the rescue! 


$Luns = Get-NcLun
foreach ($lun in $luns) { $lun.Path -replace '(?s)^.*\/', '' }


Using the NetApp PowerShell Toolkit...hope this helps...


FYI - ONTAP 9.7 would use the "-Nc*" cmdlets - not the "-Na*". 



Connect-NcController {clusterip}

$luns = (Get-NcLun).Path

 foreach ( $lun IN $luns ) {
     $lun_path = $lun.Split("/")
     $lun_name = $lun_path[$lun_path.count-1]



NetApp on Discord Image

We're on Discord, are you?

Live Chat, Watch Parties, and More!

Explore Banner

Meet Explore, NetApp’s digital sales platform

Engage digitally throughout the sales process, from product discovery to configuration, and handle all your post-purchase needs.

NetApp Insights to Action
I2A Banner