ReportServerConfig.ps1

Jan 30, 2013 at 12:51 PM

#Build: 0.02
#Author: Munib Ahmed
#Date: 2013-01-21
#Instructions: Modify the Report Server Web.config file. ie replace MSRS10_50.ANDROMEDA with your folder name

$version = "6.2.0.0"
$webConfig = "C:\Program Files\Microsoft SQL Server\MSRS10_50.ANDROMEDA\Reporting Services\ReportServer\Web.config"
$currentDate = (get-date).tostring("mm_dd_yyyy-hh_mm_s") # month_day_year - hours_mins_seconds
$backup = $webConfig + "_$currentDate"
$doc = new-object System.Xml.XmlDocument
  
$doc.Load($webConfig)

#save a backup copy
$doc.Save($backup)

# add httpModules
#Find Data
$nodeAxReportsHttpModule = $doc.documentElement.SelectSingleNode("//configuration/system.web/httpModules/add[@name='AxReportsHttpModule']")

#Add Data Extension
if (-not($nodeAxReportsHttpModule))
{
    $nodeHttpModules = $doc.documentElement.SelectSingleNode("//configuration/system.web/httpModules")
    if ($nodeHttpModules)
    {
        $nodeHttpModules.InnerXml = $nodeHttpModules.InnerXml +
        "<add name='AxReportsHttpModule' type='Microsoft.Dynamics.Framework.Reports.AxReportsHttpModule,Microsoft.Dynamics.Framework.ReportsExtensions, Version=" +
$version +
",  Culture=neutral, PublicKeyToken=31bf3856ad364e35' />"

        Write-Host  "AxReportsHttpModule"
    }
}

# set maxRequestLength="100000"
$node = $doc.get_DocumentElement()."system.web".httpRuntime  
$attribute = $doc.CreateAttribute("maxRequestLength")
$attribute.set_Value("100000")
$node.SetAttributeNode($attribute )

#Add <hostingEnvironment shadowCopyBinAssemblies="true" />
$node = $doc.get_DocumentElement()."system.web".hostingEnvironment
if ($node)
{
    $attribute = $doc.CreateAttribute("shadowCopyBinAssemblies")
    $attribute.set_Value("true")
    $node.SetAttributeNode($attribute )
    $doc.Save($webConfig)     
}
else
{
    $node = $doc.get_DocumentElement()."system.web"      
    # Add a new node
    $subnode = $doc.createElement("hostingEnvironment")
    $node.appendChild($subnode)
    $attribute = $doc.CreateAttribute("shadowCopyBinAssemblies")
    $attribute.set_Value("true")
    $subnode.SetAttributeNode($attribute )
    $doc.Save($webConfig)
}