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.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 |
$TempFile = "C:Tempnar_outTemp.nar" $OutputFile = "C:Tempnar_outNAR_Merge.nar" $NarFiles = Get-Childitem "C:Tempnar_in" $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 ++ } |
I hope someone finds this useful.
Regards,
Dave