Produced by Araxis Merge on 11/9/2018 12:16:35 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.
# | Location | File | Last Modified |
---|---|---|---|
1 | RAMS-2.3.0.zip\RAMS-2.3.0\ps | Reports_Import.ps1 | Wed Aug 22 15:15:06 2018 UTC |
2 | RAMS-2.3.0.zip\RAMS-2.3.0\ps | Reports_Import.ps1 | Fri Nov 9 14:40:14 2018 UTC |
Description | Between Files 1 and 2 |
|
---|---|---|
Text Blocks | Lines | |
Unchanged | 2 | 736 |
Changed | 1 | 2 |
Inserted | 0 | 0 |
Removed | 0 | 0 |
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 |
No regular expressions were active.
1 | <# | |
2 | ||
3 | .SYNOPSIS | |
4 | Bulk i mport SSRS Reports f rom a fold er and upd ate the re ports data source. | |
5 | ||
6 | .DESCRIPTI ON | |
7 | Makes a connecti on to the SSRS serve r. Creates the Repor ts Folder, subfolder s, and Dat a Source F olders on the | |
8 | SSRS s erver, if they do no t exist al ready. Loo ps through all the D ata Source (RDS) fil es and con figures th em on | |
9 | the SS RS server. Loops thr ough the R eport Sour ce (RDL) f iles for e ach subfol der and pa rent folde r, uploadi ng | |
10 | them t o the SSRS server. | |
11 | ||
12 | .PARAMETER webServic eUrl | |
13 | [strin g] The SSR S web serv ices URL. | |
14 | ||
15 | .PARAMETER reportFol der | |
16 | [strin g] The nam e of the f older on t he SSRS se rver where the repor ts will be imported. "RAMS Rep orts" is t he | |
17 | defaul t. | |
18 | ||
19 | .PARAMETER DataSourc esFolder | |
20 | [strin g] The nam e of the f older on t he SSRS se rver where the data sources wi ll be impo rted. "Dat a Sources" is the | |
21 | defaul t. | |
22 | ||
23 | .PARAMETER SourceDir ectory | |
24 | [strin g] The bas e director y of the r eports dir ectory in the deploy ment packa ge. Built using the RAMS relea se | |
25 | number , e.g. RAM S-2.3.0, a nd adding the report s director y. For exa mple, D:\R AMS-2.3.0\ Reports. | |
26 | ||
27 | .PARAMETER overwrite | |
28 | [boole an] if $tr ue, indica tes that t he report should be overwritte n. | |
29 | ||
30 | .PARAMETER rdsConnSt ringTable | |
31 | [hasht able] The connection strings f or the RAM S_DB, RAMS _SP, and D ataSource1 . RAMS_DB is set to | |
32 | "Data Source=$sq lServerNam e;Initial Catalog=RA MS". RAMS_ SP and Dat aSource1 a re set to $siteUrl. | |
33 | ||
34 | .PARAMETER rdsCreden tialsTable | |
35 | [hasht able] The login cred entials fo r the RAMS _DB and RA MS_SP conn ections.co ntains the SUPERREAD ER userid and | |
36 | passwo rd | |
37 | ||
38 | .EXAMPLE | |
39 | #when run from d eploymentD river.ps1 | |
40 | . $scr iptInc -we bServiceUr l "http:// $reportTar getServerN ame" -repo rtFolder " RAMS Repor ts" -DataS ourcesFold er "Data S ources" -S ourceDirec tory $repo rtSourceDi rectory -o verwrite $ True -rdsC onnStringT able $rdsC onnStringT able -rdsC redentials Table $rds Credential sTable | |
41 | ||
42 | #> | |
43 | ||
44 | Param( | |
45 | [strin g]$webServ iceUrl, | |
46 | [strin g]$reportF older = "R AMS Report s", | |
47 | [strin g]$DataSou rcesFolder = "Data S ources", | |
48 | [strin g]$SourceD irectory = $PSScript Root, | |
49 | [bool] $overwrite = $true, | |
50 | # Data Sources Co nnection s tring Tabl e | |
51 | [hasht able]$rdsC onnStringT able, | |
52 | # Data Source Cre dentials: Username a nd Passwor d if neede d | |
53 | [hasht able]$rdsC redentials Table | |
54 | ) | |
55 | ||
56 | #$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= DN S
|
|
57 | #$rdsCrede ntialsTabl e = @{"RAM S_DB" = @( "BLABLA"," BLAHBLAH") }; | |
58 | ||
59 | #Connect t o SSRS | |
60 | write-log -message " Reportserv er: $webSe rviceUrl" -consoleFo reground M agenta | |
61 | write-log -message " Estabishin g Proxy co nnection, connecting to : $web ServiceUrl /ReportSer ver/Report Service201 0.asmx?WSD L" -consol eForegroun d Gray | |
62 | write-log -message " " -conso leForegrou nd Gray | |
63 | ||
64 | $ssrsProxy = New-Web ServicePro xy -Uri $w ebServiceU rl'/Report Server/Rep ortService 2010.asmx? WSDL' -Use DefaultCre dential | |
65 | if ($ssrsP roxy -eq $ null) { | |
66 | write- log -messa ge "SSRS P roxy not c reated for URL: $web ServiceUrl /ReportSer ver/Report Service201 0.asmx?WSD L" -consol eForegroun d Red | |
67 | } else { | |
68 | write- log -messa ge "SSRS P roxy creat ed for URL : $webServ iceUrl/Rep ortServer/ ReportServ ice2010.as mx?WSDL" - consoleFor eground Gr een | |
69 | } | |
70 | ||
71 | function S SRSFolder ([string]$ reportFold er,[string ]$reportPa th){ | |
72 | <# | |
73 | ||
74 | .SYNOP SIS | |
75 | Cr eates the folder on the SSRS s erver | |
76 | ||
77 | .DESCR IPTION | |
78 | Cr eates the folder nam ed $report Folder at the locati on specifi ed by $rep ortPath | |
79 | ||
80 | .PARAM ETER repor tFolder | |
81 | [s tring] The folder na me. | |
82 | ||
83 | .PARAM ETER repor tPath | |
84 | [s tring] The path to t he folder on the SSR S server. | |
85 | ||
86 | .EXAMP LE | |
87 | SS RSFolder $ reportFold er "/" | |
88 | ||
89 | .EXAMP LE | |
90 | SS RSFolder " CIRB Repor ts" "/$rep ortFolder" | |
91 | ||
92 | #> | |
93 | ||
94 | #Creat e Folder | |
95 | try { | |
96 | $s srsProxy.C reateFolde r($reportF older, $re portPath, $null) | o ut-null | |
97 | if ($reportPa th -eq '/' ) { | |
98 | write-lo g -message "$reportp ath$report Folder Fol der Create d" -consol eForegroun d Gray | |
99 | } else { | |
100 | write-lo g -message "$reportp ath/$repor tFolder Fo lder Creat ed" -conso leForegrou nd Gray | |
101 | } | |
102 | } catc h [System. Web.Servic es.Protoco ls.SoapExc eption] { | |
103 | if ($_.Excep tion.Detai l.InnerTex t -match " rsItemAlre adyExists4 00") { | |
104 | write-lo g -message "Folder: $reportFol der alread y exists." -consoleF oreground Gray | |
105 | } else { | |
106 | $msg = " Error crea ting folde r: $report Folder. Ms g: '{0}'" -f $_.Exce ption.Deta il.InnerTe xt | |
107 | Write-Er ror $msg | |
108 | } | |
109 | } | |
110 | } | |
111 | ||
112 | function S SRSItem ([ string]$It emType,$it em,[string ]$folder) { | |
113 | <# | |
114 | ||
115 | .SYNOP SIS | |
116 | Cr eates the report ite m on the S SRS server | |
117 | ||
118 | .DESCR IPTION | |
119 | Up loads the report rdl file to t he server, creating the catalo g item for the repor t. | |
120 | ||
121 | .PARAM ETER ItemT ype | |
122 | [s tring] Typ e of item. In RAMS-2 .3.0 it is always se t to "Repo rt" | |
123 | ||
124 | .PARAM ETER item | |
125 | [o bject] The report rd l file obj ect | |
126 | ||
127 | .PARAM ETER folde r | |
128 | [s tring] The path and name of th e folder o n the SSRS server. | |
129 | ||
130 | .EXAMP LE | |
131 | SS RSItem Rep ort $rdlfi le "/$repo rtFolder/C IRB Report s" | |
132 | ||
133 | #> | |
134 | ||
135 | write- log -messa ge " " -co nsoleForeg round Gray | |
136 | #Repor tName | |
137 | if ($I temType -n e "Resourc e") { | |
138 | $I temName = [System.IO .Path]::Ge tFileNameW ithoutExte nsion($ite m); | |
139 | } else { | |
140 | $I temName = $item.Name | |
141 | } | |
142 | write- log -messa ge "$ItemN ame" -cons oleForegro und Magent a | |
143 | ||
144 | #Uploa d File | |
145 | try { | |
146 | #G et Report content in bytes | |
147 | wr ite-log -m essage "Ge tting file content o f: $item" -consoleFo reground W hite | |
148 | $b yteArray = Get-Conte nt $item.F ullName -e ncoding by te | |
149 | $m sg = "Size : {0} KB" -f "{0:N0} " -f ($byt eArray.Len gth/1KB) | |
150 | wr ite-log -m essage "$m sg" -conso leForegrou nd White | |
151 | ||
152 | wr ite-log -m essage "Up loading $i temName to folder: $ folder " - consoleFor eground Wh ite | |
153 | ||
154 | #S ets proper ty for ima ges(only p ng) | |
155 | $t ype = $ssr sProxy.Get Type().Nam espace | |
156 | $d atatype = ($type + ' .Property' ) | |
157 | $p roperty =N ew-Object ($datatype ); | |
158 | if ($ItemTyp e -eq "Res ource" -an d $item -l ike "*.png "){ | |
159 | $propert y.Name = " MimeType" | |
160 | $propert y.Value = "image/png " | |
161 | } else { | |
162 | $propert y = $null | |
163 | } | |
164 | ||
165 | #C all Proxy to upload report | |
166 | $w arnings =@ (); | |
167 | $s srsProxy.C reateCatal ogItem($It emType,$it emName,$fo lder,$over write,$byt eArray,$pr operty,[re f]$warning s) | out-n ull | |
168 | if ($warnings .Length -l e 1) { | |
169 | write-lo g -message "Upload o f $itemNam e Success. " -console Foreground Green | |
170 | } else { | |
171 | foreach ($message in $warnin gs) { | |
172 | if ( $message.C ode -ne "r sDataSourc eReference NotPublish ed"){ | |
173 | write-log -message " $($message .Severity) $($messag e.Code) $( $message.M essage)" - consoleFor eground Ye llow | |
174 | } | |
175 | } | |
176 | } | |
177 | } catc h [System. IO.IOExcep tion] { | |
178 | $m sg = "Erro r while re ading rdl file : '{0 }', Messag e: '{1}'" -f $rdlFil e, $_.Exce ption.Mess age | |
179 | Wr ite-Error $msg | |
180 | } catc h [System. Web.Servic es.Protoco ls.SoapExc eption] { | |
181 | $c aught = $f alse | |
182 | if ($_.Excep tion.Detai l.InnerTex t -match ' rsItemAlre adyExists4 00') { | |
183 | $caught = $true | |
184 | write-lo g -message "Report: $itemName already ex ists." -co nsoleForeg round Red | |
185 | } | |
186 | if ($_.Excep tion.Detai l.InnerTex t -match ' CoretechSS RS') { | |
187 | $caught = $true | |
188 | write-lo g -message "Cant't f ind Report ing Extent ion File." -consoleF oreground Red | |
189 | } elseif ($c aught -eq $false) { | |
190 | $msg = " Error uplo ading repo rt: $repor tName. Msg : '{0}'" - f $_.Excep tion.Detai l.InnerTex t | |
191 | Write-Er ror $msg | |
192 | } | |
193 | } | |
194 | } | |
195 | ||
196 | Function S SRSDatasou rce ([stri ng]$Report Path,$Data SourceName ,$DataSour cePath){ | |
197 | <# | |
198 | ||
199 | .SYNOP SIS | |
200 | Cr eates the data sourc e item on the SSRS s erver | |
201 | ||
202 | .DESCR IPTION | |
203 | Up loads the data sourc e rds file to the se rver, crea ting the c atalog ite m for the data sourc e. Each da tasource | |
204 | in the repor t is loope d through and adjust ed for the current e nvironment . | |
205 | ||
206 | .PARAM ETER Repor tPath | |
207 | [s tring] Typ e path to the report on the se rver. | |
208 | ||
209 | .PARAM ETER DataS ourceName | |
210 | [o bject] "Du mmy" becau se it does n't matter , the scri pt loops t hrough all data sour ces in the report. | |
211 | ||
212 | .PARAM ETER DataS ourcePath | |
213 | [s tring] The path to t he data so urce on th e server. | |
214 | ||
215 | .EXAMP LE | |
216 | #C hange Repo rt Datasou rce | |
217 | $ReportP ath = "/" + $reportF older + "/ CIRB Repor ts/" + [S ystem.IO.P ath]::GetF ileNameWit houtExtens ion($rdlfi le) | |
218 | $DataSou rcePath = "/" + $Dat aSourcesFo lder; | |
219 | $Datasou rceName = "dummy" | |
220 | write-lo g -message "ReportPa th: $Repor tPath Data SourcePath : $DataSou rcePath" - consoleFor eground Gr ay | |
221 | SSRSData source $Re portPath $ DataSource Name $Data SourcePath | |
222 | ||
223 | #> | |
224 | ||
225 | $repor t = $ssrsP roxy.GetIt emDataSour ces($Repor tPath) | |
226 | ForEac h ($Source in $repor t) { | |
227 | if ($DataSour cePath -ma tch "RAMS_ SP") { | |
228 | $DataSou rcePath= $ DataSource Path.Repla ce("RAMS_S P","RAMS_D B") | |
229 | } else { | |
230 | $DataSou rcePath= $ DataSource Path +"/"+ $Source.N ame; | |
231 | } | |
232 | $D ataSourceN ame=$Sourc e.Name; | |
233 | #w rite-log - message "S SRSDataSou rce for Da taSourcePa th: $DataS ourcePath DataSource Name: $Dat aSourceNam e" -consol eForegroun d White | |
234 | ||
235 | $p roxyNamesp ace = $Sou rce.GetTyp e().Namesp ace | |
236 | ||
237 | $c onstDataso urce = New -Object (" $proxyName space.Data Source") | |
238 | $c onstDataso urce.Name = $DataSou rceName | |
239 | $c onstDataso urce.Item = New-Obje ct ("$prox yNamespace .DataSourc eReference ") | |
240 | $c onstDataso urce.Item. Reference = $DataSou rcePath | |
241 | wr ite-log -m essage "SS RSDataSour ce for dat asource: $ DataSource Name DataS ourcePath: $DataSour cePath" -c onsoleFore ground Whi te | |
242 | ||
243 | $S ource.item = $constD atasource. Item | |
244 | $s srsProxy.S etItemData Sources($R eportPath, $Source) | |
245 | wr ite-log -m essage "SS RSDataSour ce for Cha nging data source: $( $Source.Na me) to $($ Source.Ite m.Referenc e)" -conso leForegrou nd White | |
246 | } | |
247 | } | |
248 | ||
249 | ##Create F older Stru cture | |
250 | #Create Ba se Folder | |
251 | SSRSFolder $reportFo lder "/" | |
252 | SSRSFolder "CIRB Rep orts" "/$r eportFolde r" | |
253 | SSRSFolder $DataSour cesFolder "/" | |
254 | ||
255 | ForEach($F older in G et-ChildIt em $Source Directory -Directory ){ | |
256 | #Add e ach folder in the so urcefolder to the re porting se rvice | |
257 | SSRSFo lder $Fold er.Name /$ reportFold er | |
258 | } | |
259 | ||
260 | #Create th e Data Sou rces | |
261 | ForEach ($ rdsfile in Get-Child Item $Sour ceDirector y -Filter *.rds ) { | |
262 | #Get t he datasou rce file n ame withou t extensio n | |
263 | $rdsFi leName = [ System.IO. Path]::Get FileNameWi thoutExten sion($rdsf ile) | |
264 | #Sourc e file | |
265 | $src = $SourceDi rectory +" /"+ $rdsfi le | |
266 | ||
267 | #Targe t folder | |
268 | $tar = "/"+ $Dat aSourcesFo lder | |
269 | ||
270 | write- log -messa ge "FOR: $ rdsFileNam e" -consol eForegroun d Gray | |
271 | ||
272 | # CREA TE A NEW D ATASOURCE OBJECT WIT H SOURCE F ILE DATA | |
273 | [xml]$ XmlDataSou rceDefinit ion = Get- Content $s rc; | |
274 | ||
275 | ||
276 | write- log -messa ge "Templa te Definit ion" -cons oleForegro und Gray | |
277 | $XmlDa taSourceDe finition.D ataSourceD efinition | |
278 | ||
279 | try { | |
280 | $t ype = $ssr sproxy.Get Type().Nam espace; | |
281 | } catc h { | |
282 | th row $_.Exc eption; | |
283 | } | |
284 | ||
285 | $dataS ourceDefin itionType = ($type + '.DataSou rceDefinit ion'); | |
286 | $dataS ourceDefin ition = Ne w-Object ( $dataSourc eDefinitio nType); | |
287 | $dataS ourceDefin ition.Exte nsion = $X mlDataSour ceDefiniti on.DataSou rceDefinit ion.Extens ion; | |
288 | ||
289 | #Set t he connect ionstring from the $ rdsConnStr ingTable p rovided | |
290 | ||
291 | if($rd sConnStrin gTable.Con tainsKey($ rdsFileNam e)){ | |
292 | if ($rdsConnS tringTable .Item($rds FileName) -ne $null -and $rdsC onnStringT able.Item( $rdsFileNa me) -ne "" ){ | |
293 | $r dsConnStri ngTable.It em($rdsFil eName); | |
294 | $dataSou rceDefinit ion.Connec tString = $rdsConnSt ringTable. Item($rdsF ileName); | |
295 | } else { | |
296 | write-lo g -message "The Conn ection str ing provid ed against Datasourc e $rdsFile Name is Nu ll or empt y" -consol eForegroun d Red | |
297 | } | |
298 | } else { | |
299 | wr ite-log -m essage "Th e Connecti on string against Da tasource $ rdsFileNam e has not been provi ded, It wi ll be set as blank/e mpty going further" -consoleFo reground R ed | |
300 | $d ataSourceD efinition. ConnectStr ing = ""; | |
301 | } | |
302 | ||
303 | $dataS ourceDefin ition.Cred entialRetr ieval = $X mlDataSour ceDefiniti on.DataSou rceDefinit ion.Creden tialRetrie val; | |
304 | $dataS ourceDefin ition.Wind owsCredent ials = $Xm lDataSourc eDefinitio n.DataSour ceDefiniti on.Windows Credential s; | |
305 | $dataS ourceDefin ition.Enab led = $Xml DataSource Definition .DataSourc eDefinitio n.Enabled; | |
306 | $dataS ourceDefin ition.Impe rsonateUse r = $XmlDa taSourceDe finition.D ataSourceD efinition. Impersonat eUser; | |
307 | ||
308 | # Set the authen tication C redentials from the $rdsCreden tialsTable | |
309 | if($rd sCredentia lsTable.Co ntainsKey( $rdsFileNa me)){ | |
310 | if ($rdsCrede ntialsTabl e.Item($rd sFileName) -ne $null -and $rds Credential sTable.Ite m($rdsFile Name).coun t -eq 2){ | |
311 | $dataSou rceDefinit ion.Creden tialRetrie val = 'Sto re'; | |
312 | $dataSou rceDefinit ion.Window sCredentia ls = $true ; | |
313 | $dataSou rceDefinit ion.UserNa me=$rdsCre dentialsTa ble.Item($ rdsFileNam e)[0]; | |
314 | $dataSou rceDefinit ion.Passwo rd=$rdsCre dentialsTa ble.Item($ rdsFileNam e)[1]; | |
315 | } else { | |
316 | write-lo g -message "The Cred entials pr ovided aga inst Datas ource $rds FileName i s Null or empty" -co nsoleForeg round Red | |
317 | } | |
318 | } | |
319 | ||
320 | write- log -messa ge "New De finition" -consoleFo reground G ray | |
321 | $dataS ourceDefin ition | |
322 | ||
323 | try { | |
324 | #C REATE THE DATASOURCE | |
325 | $n ewDataSour ce = $ssrs proxy.Crea teDataSour ce([System .IO.Path]: :GetFileNa meWithoutE xtension($ rdsfile),$ tar,$true, $dataSourc eDefinitio n,$null); | |
326 | } catc h { | |
327 | th row $_.Exc eption; | |
328 | } | |
329 | } | |
330 | ||
331 | #Upload Re ports in r oot folder | |
332 | ForEach ($ rdlfile in Get-Child Item "$Sou rceDirecto ry\CIRB Re ports" -Fi lter *.rdl ) { | |
333 | SSRSIt em Report $rdlfile " /$reportFo lder/CIRB Reports" | |
334 | #Chang e Report D atasource | |
335 | $Repor tPath = "/ " + $repor tFolder + "/CIRB Rep orts/" + [System.IO .Path]::Ge tFileNameW ithoutExte nsion($rdl file) | |
336 | $DataS ourcePath = "/" + $D ataSources Folder; | |
337 | $Datas ourceName= "dummy" | |
338 | write- log -messa ge "Report Path: $Rep ortPath Da taSourcePa th: $DataS ourcePath" -consoleF oreground Gray | |
339 | SSRSDa tasource $ ReportPath $DataSour ceName $Da taSourcePa th | |
340 | } | |
341 | ||
342 | ForEach ($ rdlfile in Get-Child Item $Sour ceDirector y -Filter *.rdl ) { | |
343 | SSRSIt em Report $rdlfile / $reportFol der | |
344 | #Chang e Report D atasource | |
345 | $Repor tPath = "/ " + $repor tFolder + "/" + [Sy stem.IO.Pa th]::GetFi leNameWith outExtensi on($rdlfil e) | |
346 | $DataS ourcePath = "/" + $D ataSources Folder; | |
347 | $Datas ourceName= "dummy" | |
348 | write- log -messa ge "Report Path: $Rep ortPath Da taSourcePa th: $DataS ourcePath" -consoleF oreground Gray | |
349 | SSRSDa tasource $ ReportPath $DataSour ceName $Da taSourcePa th | |
350 | ||
351 | } | |
352 | ||
353 | ||
354 | ##For Each folder | |
355 | <# | |
356 | ForEach($F older in G et-ChildIt em $Source Directory -Directory ) { | |
357 | #Add e ach folder in the so urcefolder to the re porting se rvice | |
358 | #SSRSF older $Fol der.Name / $Basefolde r | |
359 | ||
360 | #Add r eports in the folder | |
361 | ForEac h ($rdlfil e in Get-C hildItem $ Folder -Fi lter *.rdl ) { | |
362 | SS RSItem Rep ort $rdlfi le /$repor tFolder/$( $folder.Na me) | |
363 | ||
364 | #C hange Repo rt Datasou rce | |
365 | $R eportPath = "/" + $r eportFolde r + "/" + $folder.Na me + "/" + $rdlfile. BaseName | |
366 | #S SRSDatasou rce $Repor tPath $Dat aSourceNam e $DataSou rcePath | |
367 | } | |
368 | } | |
369 | #> |
Araxis Merge (but not the data content of this report) is Copyright © 1993-2016 Araxis Ltd (www.araxis.com). All rights reserved.