Virtualization Articles and Resources

Automate Lun Serial change after head swap or nvram change using Powershell Toolkit

This is a powershell script which automates the process of reverting a filers lun serial numbers after a head upgrade or a NVRAM change. Requires Data ONTAP Powershell Toolkit.


After the files are generated, put the files somewhere in the filers /etc directory and use the DataONTAP "source" command to call them when it's time.


Based on Romeo Theriault's .pl script:

Which was based on Karel Verhelst's .vbs script:


Run this script ahead of time against the filers you will be upgrading.


For each filer you run it against it will create three files:






It will output these files in same directory as the script is executed.

It will check if these files exist before creating new ones and will delete them if they do exist.


Place these three files somewhere in the /etc directory of the root vol of the filer and after the head upgrade, use the filers source command to run the files.



   source /etc/scripts/filername_lunoffline

   source /etc/scripts/filername_lunserial

   source /etc/scripts/filername_lunonline


Version 2 - Uses the .NET AppendAllText method of the System.IO.File class to produce output files with "LF" (Unix-type) Line Feed line breaks. (Instead of CR + LF (Windows-type) Carriage Return + Line Feed breaks.)

Please Note:

All content posted on the NetApp Community is publicly searchable and viewable. Participation in the NetApp Community is voluntary.

In accordance with our Code of Conduct and Community Terms of Use, DO NOT post or attach the following:

  • Software files (compressed or uncompressed)
  • Files that require an End User License Agreement (EULA)
  • Confidential information
  • Personal data you do not want publicly available
  • Another’s personally identifiable information (PII)
  • Copyrighted materials without the permission of the copyright owner

Continued non-compliance may result in NetApp Community account restrictions or termination.

All Community Forums