38 lines
1.3 KiB
PowerShell
38 lines
1.3 KiB
PowerShell
|
function Get-ReportServerConfiguration {
|
||
|
<#
|
||
|
.SYNOPSIS
|
||
|
Returns the Report Server Configuration XML block
|
||
|
#>
|
||
|
[CmdletBinding()]
|
||
|
[OutputType([Object])]
|
||
|
param(
|
||
|
)
|
||
|
|
||
|
$logLead = (Get-LogLeadName);
|
||
|
|
||
|
[xml]$machineConfig = Get-Content (Get-DotNetConfigPath)
|
||
|
|
||
|
if (($null -eq $machineConfig.Configuration.AppSettings) -or
|
||
|
(($machineConfig.Configuration.AppSettings.ChildNodes | Where-Object {$_.Key -match "ReportServer"}).Count -eq 0)) {
|
||
|
Write-Warning "$logLead : Could not find report server configuration in the local machine.config"
|
||
|
return $null
|
||
|
}
|
||
|
|
||
|
$reportKeys = @("ReportServer", "ReportServerPath", "ReportServerUserName", "ReportServerPassword", "ReportUserName", "ReportPassword", "Environment.Type")
|
||
|
|
||
|
$reportServerConfiguration = New-Object System.XML.XMLDocument
|
||
|
$root = $reportServerConfiguration.CreateElement("appSettings")
|
||
|
|
||
|
$appSettingsNode = $machineConfig.Configuration.AppSettings
|
||
|
|
||
|
foreach ($node in $appSettingsNode.ChildNodes | Where-Object {$reportKeys -contains $_.Key}) {
|
||
|
$newNode = $reportServerConfiguration.ImportNode($node, $false)
|
||
|
$root.AppendChild($newNode) | Out-Null
|
||
|
}
|
||
|
|
||
|
$reportServerConfiguration.AppendChild($root) | Out-Null
|
||
|
|
||
|
return $reportServerConfiguration
|
||
|
}
|
||
|
|