Home Datacenter Merge Multiple EMC NAR files with PowerShell

Merge Multiple EMC NAR files with PowerShell

by Roger Lund

First off, I wanted to my apologizes for falling so behind on my blogging. I could make a list of reasons, both personal and work related , but I’ll not, and instead say sorry.

I plan on making some headway on the blog front, both here and at vbrainstorm.com Expect to see some new changes at vbrainstorm.com soon.

Now, on to the blog post!

I recently attended a EMC training class, titled VNX Unified Storage Performance Workshop, and we worked a lot of .nar files. As soon as I got back in the office, I found I wanted to combine .nar files to get a larger date range when looking at them.

I did a little Googleing and found this post.

Merge Multiple EMC NAR files with PowerShell

by David Muegge

I spend some time working with what code he had and came up with this.

$userinput = Read-Host “Enter case # or description:”
$Date = (Get-Date -format “MM-dd-yyyy”)
$TempFile = “E:emcnar_outTemp.nar”
New-Item E:emcnar_out$Date -type directory -Force
$OutputFile = “E:emcnar_out$Date” + “Merge – $userinput” + ” – $Date” + “.nar”
$NarFiles = Get-Childitem “E:emcnar_input”

$filecount = 0
foreach($NFile in $NarFiles){

    if($filecount -eq 0){Copy-Item $NFile.FullName $OutputFile}Else{

        Copy-Item $OutputFile $TempFile
        Remove-Item $OutputFile
        ./NaviSECCli.exe analyzer -archivemerge -data $TempFile $NFile.FullName -out $OutputFile

    }

    $filecount ++
}

 It prompts you for the case# or a description of your choice. It will append this into the file name.
 This outputs the files to E:emcnar_out with a sub-folder for the date. with a temp location of E:emcnar_outTemp.nar. The output file name come out like Merge – input – date .nar

Credit goes to David for the original script.

I hope someone gets some use from this.

Roger Lund

You may also like