15. EPMO Open Source Coordination Office Redaction File Detail Report

Produced by Araxis Merge on 7/17/2018 6:16:26 PM Eastern Daylight Time. See www.araxis.com for information about Merge. This report uses XHTML and CSS2, and is best viewed with a modern standards-compliant browser. For optimum results when printing this report, use landscape orientation and enable printing of background images and colours in your browser.

15.1 Files compared

# Location File Last Modified
1 RAMS-2.3.0.zip\RAMS-2.3.0\ps Reports_Import.ps1 Tue Apr 24 23:53:56 2018 UTC
2 RAMS-2.3.0.zip\RAMS-2.3.0\ps Reports_Import.ps1 Tue Jul 17 20:41:50 2018 UTC

15.2 Comparison summary

Description Between
Files 1 and 2
Text Blocks Lines
Unchanged 2 656
Changed 1 4
Inserted 0 0
Removed 0 0

15.3 Comparison options

Whitespace
Character case Differences in character case are significant
Line endings Differences in line endings (CR and LF characters) are ignored
CR/LF characters Not shown in the comparison detail

15.4 Active regular expressions

No regular expressions were active.

15.5 Comparison detail

  1   <#
  2   .SYNOPSIS
  3       Bulk i mport SSRS  Reports f rom a fold er and upd ate the re ports data  source.
  4   .DESCRIPTI ON
  5       This s cript take s all the  RDL files  in a folde r and impo rts them i nto a SSRS  and updat es the rep orts data  source to  the Config mgr shared  data sour ce.
  6   #>
  7  
  8   Param(
  9      [string ]$webServi ceUrl,
  10         
  11      [string ]$reportFo lder = "RA MS Reports ",
  12  
  13      [string ]$DataSour cesFolder  = "Data So urces",
  14  
  15      [string ]$SourceDi rectory =  $PSScriptR oot,
  16  
  17      [bool]$ overwrite  = $true,
  18  
  19      # DataS ources Con nection st ring Table
  20      [hashta ble]$rdsCo nnStringTa ble,
  21  
  22      # DataS ource Cred entials: U sername an d Password  if needed
  23      [hashta ble]$rdsCr edentialsT able
  24      )
  25  
  26        #$rdsConnS tringTable  = @{ "RAM S_SP" = "h ttp://vaww .itst.ram. msp.va.gov /sites/IRB Applicatio ns/" ; "Da taSource1"  = "http:/ /vaww.itst .ram.msp.v a.gov/site s/IRBAppli cations/";  "test" =  "Data Sour ce= DN S   ;Initial C atalog=RAM S"};
  27        #$rdsCrede ntialsTabl e = @{"RAM S_DB" = @( "
A I ","
A I ")};
  28  
  29   #Connect t o SSRS
  30   Write-Host  "Reportse rver: $web ServiceUrl " -Foregro undColor D arkMagenta
  31   Write-Host  "Estabish ing Proxy  connection , connecti ng to : $w ebServiceU rl/ReportS erver/Repo rtService2 010.asmx?W SDL"
  32   Write-Host  ""
  33  
  34   $ssrsProxy  = New-Web ServicePro xy -Uri $w ebServiceU rl'/Report Server/Rep ortService 2010.asmx? WSDL' -Use DefaultCre dential
  35   $ssrsProxy
  36  
  37  
  38   function S SRSFolder  ([string]$ reportFold er,[string ]$reportPa th)
  39   {
  40      
  41   #Create Fo lder     
  42           tr y
  43           {
  44                $ssrsPro xy.CreateF older($rep ortFolder,  $reportPa th, $null)  | out-nul l
  45                if($repo rtPath -eq  '/')
  46                {
  47                Write-Ho st "Folder  `"$report path$repor tFolder`"  Created"
  48  
  49                }
  50                else
  51                {
  52                Write-Ho st "Folder  `"$report path/$repo rtFolder`"  Created"
  53                }
  54           }
  55           ca tch [Syste m.Web.Serv ices.Proto cols.SoapE xception]
  56           {
  57                if ($_.E xception.D etail.Inne rText -mat ch "rsItem AlreadyExi sts400")
  58                {
  59                    Writ e-Host "Fo lder: $rep ortFolder  already ex ists."
  60                }
  61                else
  62                {
  63                    $msg  = "Error  creating f older: $re portFolder . Msg: '{0 }'" -f $_. Exception. Detail.Inn erText
  64                    Writ e-Error $m sg
  65                }
  66           }
  67   }
  68  
  69   Function S SRSItem ([ string]$It emType,$it em,[string ]$folder)
  70    {
  71    Write-hos t ""
  72    #ReportNa me
  73    if ($Item Type -ne " Resource")
  74    {
  75    $ItemName  = [System .IO.Path]: :GetFileNa meWithoutE xtension($ item);
  76    }
  77    else
  78    {
  79    $ItemName  = $item.N ame
  80    }
  81    write-hos t $ItemNam e -Foregro undColor G reen 
  82  
  83    #Upload F ile
  84        try
  85       {
  86           #G et Report  content in  bytes
  87           Wr ite-Host " Getting fi le content  of : $ite m"
  88           $b yteArray =  Get-Conte nt $item.F ullName -e ncoding by te
  89           $m sg = "Size : {0} KB"  -f "{0:N0} " -f ($byt eArray.Len gth/1KB) 
  90           Wr ite-Host $ msg 
  91           
  92           Wr ite-Host " Uploading  to: $folde r"
  93    
  94           #S ets proper ty for ima ges(only p ng)
  95           $t ype = $ssr sProxy.Get Type().Nam espace
  96           $d atatype =  ($type + ' .Property' )               
  97           $p roperty =N ew-Object  ($datatype );
  98           if  ($ItemTyp e -eq "Res ource" -an d $item -l ike "*.png ")
  99           {
  100           $p roperty.Na me = "Mime Type"
  101           $p roperty.Va lue = “ima ge/png”
  102           }
  103           el se
  104           {
  105           $p roperty =  $null
  106           }
  107  
  108           #C all Proxy  to upload  report  
  109           $w arnings =@ ();    
  110           $s srsProxy.C reateCatal ogItem($It emType,$it emName,$fo lder,$over write,$byt eArray,$pr operty,[re f]$warning s) | out-n ull
  111           if ($warnings .Length -l e 1) { Wri te-Host "U pload Succ ess." -For egroundCol or Green }
  112           el se 
  113           {         
  114                foreach  ($message  in $warnin gs)
  115                    {
  116                    if ( $message.C ode -ne "r sDataSourc eReference NotPublish ed")
  117                         {
  118                         write-host  "$($messa ge.Severit y) $($mess age.Code)  $($message .Message)"  -Foregrou ndColor Ye llow
  119                         }
  120                    }
  121           }
  122       }
  123       catch  [System.IO .IOExcepti on]
  124       {
  125           $m sg = "Erro r while re ading rdl  file : '{0 }', Messag e: '{1}'"  -f $rdlFil e, $_.Exce ption.Mess age
  126           Wr ite-Error  msg
  127       }
  128       catch  [System.We b.Services .Protocols .SoapExcep tion]
  129    {
  130       $caugh t = $false
  131                if ($_.E xception.D etail.Inne rText -mat ch 'rsItem AlreadyExi sts400')
  132                {
  133                    $cau ght = $tru e
  134                    Writ e-Host "Re port: $ite mName alre ady exists ." -Foregr oundColor  Red
  135                }
  136                if ($_.E xception.D etail.Inne rText -mat ch 'Corete chSSRS')
  137                {
  138                    $cau ght = $tru e
  139                    Writ e-Host "Ca nt't find  Reporting  Extention  File." -Fo regroundCo lor Red
  140                }
  141                elseif ( $caught -e q $false)
  142                {
  143                    $msg  = "Error  uploading  report: $r eportName.  Msg: '{0} '" -f $_.E xception.D etail.Inne rText
  144                    Writ e-Error $m sg
  145                }
  146     
  147    }
  148   }
  149  
  150   Function S SRSDatasou rce ([stri ng]$Report Path,$Data SourceName ,$DataSour cePath)
  151   {
  152   $report =  $ssrsProxy .GetItemDa taSources( $ReportPat h)
  153   ForEach ($ Source in  $report)
  154       {
  155       if($Da taSourcePa th -match  "RAMS_SP")  {
  156           $D ataSourceP ath= $Data SourcePath .Replace(" RAMS_SP"," RAMS_DB")
  157       } else  {
  158           $D ataSourceP ath= $Data SourcePath  +"/"+ $So urce.Name;
  159       }
  160  
  161       echo " in SSRSDat aSource Da taSourcePA th" $DataS ourcePath;
  162  
  163       $DataS ourceName  =$Source.N ame;
  164       echo " in SSRSDat aSource Da taSourceNa me" $DataS ourceName;
  165  
  166  
  167       $proxy Namespace  = $Source. GetType(). Namespace
  168       
  169           $c onstDataso urce = New -Object (" $proxyName space.Data Source")
  170           $c onstDataso urce.Name  = $DataSou rceName
  171           $c onstDataso urce.Item  = New-Obje ct ("$prox yNamespace .DataSourc eReference ")
  172           $c onstDataso urce.Item. Reference  = $DataSou rcePath
  173  
  174      $Source .item = $c onstDataso urce.Item
  175       $ssrsP roxy.SetIt emDataSour ces($Repor tPath, $So urce)
  176       Write- Host "Chan ging datas ource `"$( $Source.Na me)`" to $ ($Source.I tem.Refere nce)"
  177       }
  178   }
  179  
  180   ##Create F older Stru cture
  181   #Create Ba se Folder
  182   SSRSFolder  $reportFo lder "/"
  183   SSRSFolder  "CIRB Rep orts" "/$r eportFolde r"
  184   SSRSFolder  $DataSour cesFolder  "/"
  185  
  186   ForEach($F older in G et-ChildIt em $Source Directory  -Directory )
  187       {
  188       #Add e ach folder  in the so urcefolder  to the re porting se rvice 
  189       SSRSFo lder $Fold er.Name /$ reportFold er
  190       
  191       }
  192  
  193       #Creat e the Data  Sources
  194       ForEac h ($rdsfil e in Get-C hildItem $ SourceDire ctory -Fil ter *.rds  )
  195  
  196   #Get the d atasource  file name  without ex tension
  197   $rdsFileNa me = [Syst em.IO.Path ]::GetFile NameWithou tExtension ($rdsfile)
  198   #Source fi le
  199   $src = $So urceDirect ory +"/"+  $rdsfile
  200  
  201   #Target fo lder
  202   $tar = "/" + $DataSou rcesFolder
  203  
  204   Write-Host  "FOR:" $r dsFileName
  205  
  206   # CREATE A  NEW DATAS OURCE OBJE CT WITH SO URCE FILE  DATA
  207   [xml]$XmlD ataSourceD efinition  = Get-Cont ent $src;
  208       
  209  
  210       Write- Host "Temp ;late Defi nition"
  211       $XmlDa taSourceDe finition.D ataSourceD efinition
  212  
  213       try
  214       { 
  215           $t ype = $ssr sproxy.Get Type().Nam espace;
  216       }
  217       catch
  218       { 
  219           th row $_.Exc eption;
  220       }
  221       
  222       $dataS ourceDefin itionType  = ($type +  '.DataSou rceDefinit ion');
  223       $dataS ourceDefin ition = Ne w-Object ( $dataSourc eDefinitio nType);
  224       $dataS ourceDefin ition.Exte nsion = $X mlDataSour ceDefiniti on.DataSou rceDefinit ion.Extens ion;
  225  
  226  
  227  
  228       #Set t he connect ionstring  from the $ rdsConnStr ingTable p rovided
  229  
  230       if($rd sConnStrin gTable.Con tainsKey($ rdsFileNam e)){
  231  
  232           if ($rdsConnS tringTable .Item($rds FileName)  -ne $null  -and $rdsC onnStringT able.Item( $rdsFileNa me) -ne ""  ){
  233           $r dsConnStri ngTable.It em($rdsFil eName);
  234                $dataSou rceDefinit ion.Connec tString =  $rdsConnSt ringTable. Item($rdsF ileName);
  235           }
  236           el se{
  237                Write-Ho st "The Co nnection s tring prov ided again st Datasou rce" $rdsF ileName "i s Null or  empty" -fo regroundco lor Red
  238           }
  239       }
  240       else{
  241           Wr ite-Host " The Connec tion strin g against  Datasource " $rdsFile Name "has  not been p rovided, I t will be  set as bla nk/empty g oing furth er" -foreg roundcolor  Red
  242                         $dataSourc eDefinitio n.ConnectS tring = "" ;
  243  
  244       }
  245  
  246       $dataS ourceDefin ition.Cred entialRetr ieval = $X mlDataSour ceDefiniti on.DataSou rceDefinit ion.Creden tialRetrie val;
  247       $dataS ourceDefin ition.Wind owsCredent ials = $Xm lDataSourc eDefinitio n.DataSour ceDefiniti on.Windows Credential s;
  248       $dataS ourceDefin ition.Enab led = $Xml DataSource Definition .DataSourc eDefinitio n.Enabled;
  249       $dataS ourceDefin ition.Impe rsonateUse r = $XmlDa taSourceDe finition.D ataSourceD efinition. Impersonat eUser;
  250       
  251  
  252       # Set  the authen tication C redentials  from the  $rdsCreden tialsTable
  253  
  254       if($rd sCredentia lsTable.Co ntainsKey( $rdsFileNa me)){
  255  
  256           if ($rdsCrede ntialsTabl e.Item($rd sFileName)  -ne $null  -and $rds Credential sTable.Ite m($rdsFile Name).coun t -eq 2){
  257                
  258                $dataSou rceDefinit ion.Creden tialRetrie val = 'Sto re';
  259                $dataSou rceDefinit ion.Window sCredentia ls = $true ;
  260                $dataSou rceDefinit ion.UserNa me=$rdsCre dentialsTa ble.Item($ rdsFileNam e)[0];
  261                $dataSou rceDefinit ion.Passwo rd=$rdsCre dentialsTa ble.Item($ rdsFileNam e)[1];
  262           }
  263           el se{
  264                Write-Ho st "The Cr edentials  provided a gainst Dat asource" $ rdsFileNam e "is Null  or empty"  -foregrou ndcolor Re d
  265           }
  266       }
  267       
  268       Write- Host "New  Definition "
  269       $dataS ourceDefin ition
  270  
  271       try
  272       { 
  273           #C REATE THE  DATASOURCE
  274           $n ewDataSour ce = $ssrs proxy.Crea teDataSour ce([System .IO.Path]: :GetFileNa meWithoutE xtension($ rdsfile),$ tar,$true, $dataSourc eDefinitio n,$null); 
  275       }
  276       catch
  277       { 
  278           th row $_.Exc eption; 
  279       }
  280  
  281  
  282   }
  283  
  284        
  285   #Upload Re ports in r oot folder
  286   ForEach ($ rdlfile in  Get-Child Item "$Sou rceDirecto ry\CIRB Re ports" -Fi lter *.rdl  )
  287   {
  288   SSRSItem R eport $rdl file "/$re portFolder /CIRB Repo rts"
  289   #Change Re port Datas ource
  290       $Repor tPath = "/ " + $repor tFolder +  "/CIRB Rep orts/" +   [System.IO .Path]::Ge tFileNameW ithoutExte nsion($rdl file)
  291       $DataS ourcePath  = "/" + $D ataSources Folder;
  292       $Datas ourceName=  "dummy"
  293       echo " ReportPath " $ReportP ath
  294       echo " DataSource Path" $Dat aSourcePat h
  295       SSRSDa tasource $ ReportPath  $DataSour ceName $Da taSourcePa th
  296   }
  297  
  298   ForEach ($ rdlfile in  Get-Child Item $Sour ceDirector y -Filter  *.rdl )
  299   {
  300   SSRSItem R eport $rdl file /$rep ortFolder
  301   <#Change R eport Data source
  302       $Repor tPath = "/ " + $repor tFolder +  "/" +  [Sy stem.IO.Pa th]::GetFi leNameWith outExtensi on($rdlfil e)
  303       $DataS ourcePath  = "/" + $D ataSources Folder;
  304       $Datas ourceName=  "dummy"
  305       echo " ReportPath " $ReportP ath
  306       echo " DataSource Path" $Dat aSourcePat h
  307       SSRSDa tasource $ ReportPath  $DataSour ceName $Da taSourcePa th
  308   #>
  309   }
  310  
  311  
  312   ##For Each  folder
  313   <#
  314   ForEach($F older in G et-ChildIt em $Source Directory  -Directory )
  315       {
  316       #Add e ach folder  in the so urcefolder  to the re porting se rvice 
  317       #SSRSF older $Fol der.Name / $Basefolde
  318       
  319       #Add r eports in  the folder
  320       ForEac h ($rdlfil e in Get-C hildItem $ Folder -Fi lter *.rdl  )
  321           {
  322                SSRSItem  Report $r dlfile /$r eportFolde r/$($folde r.Name) 
  323  
  324                #Change  Report Dat asource
  325                $ReportP ath = "/"  + $reportF older + "/ " + $folde r.Name + " /" + $rdlf ile.BaseNa me 
  326                #SSRSDat asource $R eportPath  $DataSourc eName $Dat aSourcePat h
  327           }
  328       }
  329  
  330   #>