SSRSRDLComparator.psm1
<#
.SYNOPSIS This command will compare the 2 SSRS RDL Files and generate a result in XML format in either Console Window or on a Source File path .DESCRIPTION The Result can be generated on either Console or File. This can be decided by The options provided in ResultOuput Property The Result is a comparision of the XML files generated of the SSRS RDL files. The Result contains 2 sets with the Line Number and the text for which there is a mismatch The first set contains the Objects that are either Extra or Changed from OriginalRDL The second set contains the Objects that are either Extra or Changed from ChangedRDL The Results sometimes might not be straight forward, as a result when File Option is chosen , the XML's for both the SSRS RDL files are available on the path where Result is generated. This XML can now be used along with the Results XML as they can be useful to understand the differnces more clearly. Use "Verbose" Option to get more details about the Operation / Process performed, as Comparision might take some time .PARAMETER OriginalRDLPath Accepts the path where First / Original SSRS RDL file is placed .PARAMETER ChangedRDLPath Accepts the path where Second / Changed SSRS RDLis placed. .PARAMETER ResultOutput Accepts either Console or File, to determine where result is to be shown / placed. .EXAMPLE Compare-SSRSRDL -OriginalRDLPath 'C:\Users\SSAS\AdventureWorksDev.RDL' -ChangedRDLPath 'C:\Users\SSAS\AdventureWorksTest.RDL' -ResultOutput Console -Verbose Compare-SSRSRDL -OriginalRDLPath 'C:\Users\SSAS\AdventureWorksDev.RDL' -ChangedRDLPath 'C:\Users\SSAS\AdventureWorksTest.RDL' -ResultOutput File -Verbose #> Function Compare-SSRSRDL { Param ( [Parameter(Mandatory=$true)] [string] $OriginalRDLPath , [Parameter(Mandatory=$true)] [string] $ChangedRDLPath, [Parameter(Mandatory=$true)] [ValidateSet('Console','File')] [string] $ResultOutput ) $Stopwatch = [system.diagnostics.stopwatch]::StartNew() Write-Verbose 'Starting Process of Comparing RDL' $Counter = 1 Write-Verbose 'Reading RDL Files' $RDL1Path = $OriginalRDLPath $RDL2Path = $ChangedRDLPath Write-Verbose "Time Elapsed in Seconds : $($StopWatch.Elapsed)" FUNCTION GenerateXML ( [string] $RDLPATH , [int] $Cnt ) { $CopyPath = $RDLPATH.Substring(0, $RDLPATH.lastIndexOf('\')) $OriginalFileNm = (Get-Item -Path $RDLPATH).Name $XMLFileNm=$OriginalFileNm.Substring(0, $OriginalFileNm.LastIndexOf('.')) $CopyPathM = $CopyPath + '\' + $Cnt + $XMLFileNm+'.XML' Copy-Item -Path $RDLPATH -Destination $CopyPathM -Force $XMLA= Get-Content -Path $CopyPathM | %{$i = 1} { new-object psobject -prop @{LineNum=$i;Text=$_}; $i++} Return $XMLA } $RDL1 = GenerateXML -RDLPATH $RDL1Path -Cnt $Counter $Counter = $Counter + 1 $RDL2 = GenerateXML -RDLPATH $RDL2Path -Cnt $Counter Write-Verbose "Time Elapsed in Seconds : $($StopWatch.Elapsed)" $Difference = Compare-Object $RDL1 $RDL2 -Property Text -PassThru $Result_File1 = $Difference | Where-Object -Property SideIndicator -EQ "<=" $Result_File2 = $Difference | Where-Object -Property SideIndicator -EQ "=>" $ResultPath = $RDL1Path.Substring(0, $RDL1Path.lastIndexOf('\')) IF($ResultOutput -eq 'Console') { Write-Host 'Changes / Addtions in Original RDL' $Result_File1 | Select-Object LineNum,Text Write-Host 'Changes / Addtions in Changed RDL' $Result_File2 | Select-Object LineNum,Text } Else { $Result1Path = $ResultPath + '\' + 'Results_Changed_Or_Additional_Components_in_OriginalRDL.txt' $Result2Path = $ResultPath + '\' + 'Results_Changed_Or_Additional_Components_in_ChangedRDL.txt' $Result_File1 | Select-Object LineNum,Text | Out-File -FilePath $Result1Path $Result_File2 | Select-Object LineNum,Text | Out-File -FilePath $Result2Path Write-Verbose 'Results are generated in XML Format , However if a comparision is not clear 2 Extra XML Files of RDL for Original and Changed are also created with results on the same path as that of Original RDL ' Write-Verbose "Results for Changes / Addtion in Original RDL is placed on : $($Result1Path)" Write-Verbose "Results for Changes / Addtion in Changed RDL is placed on : $($Result2Path)" } Write-Verbose 'Process Complete' Write-Verbose "Time Elapsed in Seconds : $($StopWatch.Elapsed)" } Export-ModuleMember -Function Compare-SSRSRDL |