Merge Multiple EMC NAR files with PowerShell

While working on a project the other day I found the need to merge multiple NAR files. The NaviSecCLI provides a method to merge two NAR files but does not allow an option to merge multiple files. I was searching on the web for methods to do this and ran across a couple of scripts.

The first script I found was done in VBScript http://blog.edgoad.com/2011/03/merging-multiple-emc-nar-files.html

The second script I found was bash for linux http://jslabonte.wordpress.com/2012/02/01/how-to-merge-nar-files/

I thought this is something that PowerShell can do much easier so here is a script to merge multiple NAR files. This script will require the NaviSecCLI to be installed to work properly.

I hope someone finds this useful.

Regards,

Dave

Leave a Reply

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

5 comments

  1. Sean Fuller says:

    Just wanted to let you know someone did find it useful. I tried the VBScript you referenced in the beginning of your article but I was getting errors with it so I thought I’d give your PowerShell script a shot. I’ve never used PowerShell before so I had to get over the quick learning curve of starting PowerShell, setting it to allow unsigned scripts to run, and learning a little bit of it’s syntax. Once I muddled my way through that, I had it merge 18 NAR files for me without a hitch. Thanks a bunch!

  2. Erick Moore says:

    Hey Dave, it’s Erick from NetApp; haven’t talked to you in a while! I would just point out that the analyzer display in Unisphere/Navisphere can only display 156 data points. This is important to note if you open the NAR files in those utilities for analysis as your results will get heavily flattened if you are trying to do something like view a week’s worth of data.

  3. dmuegge says:

    Erik,

    Nice to hear from you. Good point, I didn’t really think of that perspective. I generally use this to merge NAR files for import into some EMC internal tools.

    Thanks,

    Dave

  4. suraj says:

    Hi Dave,

    can you please explain how your script works. When I use this script to merge nar files I get following error
    emove-Item : Cannot find path ‘C:Tempnar_outNAR_Merge.nar’ because it does not exist.
    At C:Tempscript.ps1:12 char:20
    + Remove-Item <<<< $OutputFile
    + CategoryInfo : ObjectNotFound: (C:Tempnar_outNAR_Merge.nar:String) [Remove-I
    ion
    + FullyQualifiedErrorId : PathNotFound,Microsoft.PowerShell.Commands.RemoveItemCommand

    Copy-Item : Container cannot be copied onto existing leaf item.
    At C:Tempscript.ps1:11 char:18
    + Copy-Item <<<< $OutputFile $TempFile
    + CategoryInfo : InvalidArgument: (C:Tempnar_outNAR_Merge.nar:String) [Copy-Item], PSArgumentException
    + FullyQualifiedErrorId : CopyContainerItemToLeafError,Microsoft.PowerShell.Commands.CopyItemCommand

    Do the script a Temp.nar in the Temp directory.
    If the script is running for the first time then I believe that “NAR_Merge.nar” is not present.