7. EPMO Open Source Coordination Office Redaction File Detail Report

Produced by Araxis Merge on 1/16/2018 5:28:59 PM Eastern Standard 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.

7.1 Files compared

# Location File Last Modified
1 RAMS-2.2.0.zip\RAMS-2.2.0\ps Reports_Import.ps1 Fri Oct 20 13:24:50 2017 UTC
2 RAMS-2.2.0.zip\RAMS-2.2.0\ps Reports_Import.ps1 Tue Jan 16 21:47:43 2018 UTC

7.2 Comparison summary

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

7.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

7.4 Active regular expressions

No regular expressions were active.

7.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:// DNS . URL /sites/IRB Applicatio ns/" ; "Da taSource1"  = "http:/ / DNS . URL /sites/IRB Applicatio ns/"; "tes t" = "Data  Source= DNS    DN S
;Initial C atalog=RAM S"};
  27      #$rdsCr edentialsT able = @{" RAMS_DB" =  @("BLABLA ","&35Dkc> Av+KX")};
  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       $DataS ourcePath=  $DataSour cePath +"/ "+ $Source .Name;
  156       echo " in SSRSDat aSource Da taSourcePA th" $DataS ourcePath;
  157  
  158       $DataS ourceName  =$Source.N ame;
  159       echo " in SSRSDat aSource Da taSourceNa me" $DataS ourceName;
  160  
  161  
  162       $proxy Namespace  = $Source. GetType(). Namespace
  163       
  164           $c onstDataso urce = New -Object (" $proxyName space.Data Source")
  165           $c onstDataso urce.Name  = $DataSou rceName
  166           $c onstDataso urce.Item  = New-Obje ct ("$prox yNamespace .DataSourc eReference ")
  167           $c onstDataso urce.Item. Reference  = $DataSou rcePath
  168  
  169      $Source .item = $c onstDataso urce.Item
  170       $ssrsP roxy.SetIt emDataSour ces($Repor tPath, $So urce)
  171       Write- Host "Chan ging datas ource `"$( $Source.Na me)`" to $ ($Source.I tem.Refere nce)"
  172       }
  173   }
  174  
  175   ##Create F older Stru cture
  176   #Create Ba se Folder
  177   SSRSFolder  $reportFo lder "/"
  178   SSRSFolder  $DataSour cesFolder  "/"
  179  
  180   ForEach($F older in G et-ChildIt em $Source Directory  -Directory )
  181       {
  182       #Add e ach folder  in the so urcefolder  to the re porting se rvice 
  183       SSRSFo lder $Fold er.Name /$ reportFold er
  184       
  185       }
  186  
  187       #Creat e the Data  Sources
  188       ForEac h ($rdsfil e in Get-C hildItem $ SourceDire ctory -Fil ter *.rds  )
  189  
  190   #Get the d atasource  file name  without ex tension
  191   $rdsFileNa me = [Syst em.IO.Path ]::GetFile NameWithou tExtension ($rdsfile)
  192   #Source fi le
  193   $src = $So urceDirect ory +"/"+  $rdsfile
  194  
  195   #Target fo lder
  196   $tar = "/" + $DataSou rcesFolder
  197  
  198   Write-Host  "FOR:" $r dsFileName
  199  
  200   # CREATE A  NEW DATAS OURCE OBJE CT WITH SO URCE FILE  DATA
  201   [xml]$XmlD ataSourceD efinition  = Get-Cont ent $src;
  202       
  203  
  204       Write- Host "Temp ;late Defi nition"
  205       $XmlDa taSourceDe finition.D ataSourceD efinition
  206  
  207       try
  208       { 
  209           $t ype = $ssr sproxy.Get Type().Nam espace;
  210       }
  211       catch
  212       { 
  213           th row $_.Exc eption;
  214       }
  215       
  216       $dataS ourceDefin itionType  = ($type +  '.DataSou rceDefinit ion');
  217       $dataS ourceDefin ition = Ne w-Object ( $dataSourc eDefinitio nType);
  218       $dataS ourceDefin ition.Exte nsion = $X mlDataSour ceDefiniti on.DataSou rceDefinit ion.Extens ion;
  219  
  220  
  221  
  222       #Set t he connect ionstring  from the $ rdsConnStr ingTable p rovided
  223  
  224       if($rd sConnStrin gTable.Con tainsKey($ rdsFileNam e)){
  225  
  226           if ($rdsConnS tringTable .Item($rds FileName)  -ne $null  -and $rdsC onnStringT able.Item( $rdsFileNa me) -ne ""  ){
  227           $r dsConnStri ngTable.It em($rdsFil eName);
  228                $dataSou rceDefinit ion.Connec tString =  $rdsConnSt ringTable. Item($rdsF ileName);
  229           }
  230           el se{
  231                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
  232           }
  233       }
  234       else{
  235           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
  236                         $dataSourc eDefinitio n.ConnectS tring = "" ;
  237  
  238       }
  239  
  240       $dataS ourceDefin ition.Cred entialRetr ieval = $X mlDataSour ceDefiniti on.DataSou rceDefinit ion.Creden tialRetrie val;
  241       $dataS ourceDefin ition.Wind owsCredent ials = $Xm lDataSourc eDefinitio n.DataSour ceDefiniti on.Windows Credential s;
  242       $dataS ourceDefin ition.Enab led = $Xml DataSource Definition .DataSourc eDefinitio n.Enabled;
  243       $dataS ourceDefin ition.Impe rsonateUse r = $XmlDa taSourceDe finition.D ataSourceD efinition. Impersonat eUser;
  244       
  245  
  246       # Set  the authen tication C redentials  from the  $rdsCreden tialsTable
  247  
  248       if($rd sCredentia lsTable.Co ntainsKey( $rdsFileNa me)){
  249  
  250           if ($rdsCrede ntialsTabl e.Item($rd sFileName)  -ne $null  -and $rds Credential sTable.Ite m($rdsFile Name).coun t -eq 2){
  251                
  252                $dataSou rceDefinit ion.Creden tialRetrie val = 'Sto re';
  253                $dataSou rceDefinit ion.Window sCredentia ls = $true ;
  254                $dataSou rceDefinit ion.UserNa me=$rdsCre dentialsTa ble.Item($ rdsFileNam e)[0];
  255                $dataSou rceDefinit ion.Passwo rd=$rdsCre dentialsTa ble.Item($ rdsFileNam e)[1];
  256           }
  257           el se{
  258                Write-Ho st "The Cr edentials  provided a gainst Dat asource" $ rdsFileNam e "is Null  or empty"  -foregrou ndcolor Re d
  259           }
  260       }
  261       
  262       Write- Host "New  Definition "
  263       $dataS ourceDefin ition
  264  
  265       try
  266       { 
  267           #C REATE THE  DATASOURCE
  268           $n ewDataSour ce = $ssrs proxy.Crea teDataSour ce([System .IO.Path]: :GetFileNa meWithoutE xtension($ rdsfile),$ tar,$true, $dataSourc eDefinitio n,$null); 
  269       }
  270       catch
  271       { 
  272           th row $_.Exc eption; 
  273       }
  274  
  275  
  276   }
  277  
  278        
  279   #Upload Re ports in r oot folder
  280   ForEach ($ rdlfile in  Get-Child Item $Sour ceDirector y -Filter  *.rdl )
  281   {
  282   SSRSItem R eport $rdl file /$rep ortFolder
  283   <#Change R eport Data source
  284       $Repor tPath = "/ " + $repor tFolder +  "/" +  [Sy stem.IO.Pa th]::GetFi leNameWith outExtensi on($rdlfil e)
  285       $DataS ourcePath  = "/" + $D ataSources Folder;
  286       $Datas ourceName=  "dummy"
  287       echo " ReportPath " $ReportP ath
  288       echo " DataSource Path" $Dat aSourcePat h
  289       SSRSDa tasource $ ReportPath  $DataSour ceName $Da taSourcePa th
  290   #>
  291   }
  292  
  293   ##For Each  folder
  294   ForEach($F older in G et-ChildIt em $Source Directory  -Directory )
  295       {
  296       #Add e ach folder  in the so urcefolder  to the re porting se rvice 
  297       #SSRSF older $Fol der.Name / $Basefolde
  298       
  299       #Add r eports in  the folder
  300       ForEac h ($rdlfil e in Get-C hildItem $ Folder -Fi lter *.rdl  )
  301           {
  302           SS RSItem Rep ort $rdlfi le /$repor tFolder/$( $folder.Na me) 
  303  
  304           #C hange Repo rt Datasou rce
  305           $R eportPath  = "/" + $r eportFolde r + "/" +  $folder.Na me + "/" +  $rdlfile. BaseName 
  306           #S SRSDatasou rce $Repor tPath $Dat aSourceNam e $DataSou rcePath
  307           }
  308       }