Wednesday, March 21, 2012

PowerShell - Report Server Integration - Part 3

After configuring SS2008, SP2010 needs to have its Report Server Integration configured.  The manual process takes care of both defining the configuration and activating the feature.

To manually do so, read http://msdn.microsoft.com/en-us/library/bb326213.aspx.

Because the manual process really takes two separate actions, this post will focus on configuring SP2010 Report Server Integration.  The next post will focus on activating the Report Server Integration feature in existing site collections.

The script below will perform the following steps:
1)  Find the existing configuration and delete it.
2)  Create the new configuration, defining its properties
3)  Apply the new configuration to the farm.

# ###############################################
# ##### Configure SharePoint Report Server Integration #####
# ###############################################

try
{
    Write-Log $logFile "Being configuration of SharePoint 2010 Report Server Integration" $lvlInfo

    # Load the library that contains the SPRSSServiceConfiguration class.
    [Reflection.Assembly]::LoadWithPartialName(“Microsoft.ReportingServices.SharePoint.Common”) | Out-Null

    # Retrieve the name of the service from a string constant.  Placed in a local variable for “short-hand” use later
    $serviceName = [Microsoft.ReportingServices.SharePoint.Common.SPRSServiceConfiguration]::RSServiceName

    # Get the current SharePoint farm.
    $spFarm = Get-SPFarm

    # Find all SPService objects that are of the SPRSServiceConfiguration type
    $rsServiceList = [array] $spFarm.Services | Where {$_.TypeName -eq "Microsoft.ReportingServices.SharePoint.Common.SPRSServiceConfiguration"}

    if($rsServiceList -ne $null)
    {
        # Delete any found SPService objects.  We will be making a new one for our configuration purproses
        $rsServiceList | %{$_.Delete()}
    }
       
    # Generate a new SPRSServiceConfiguration object for the Report Server Integration on the SharePoint farm.
    $ssrs = new-object -typeName Microsoft.ReportingServices.SharePoint.Common.SPRSServiceConfiguration($serviceName, $spFarm)

    # Set the configuration properties to work with the SQL Server configuration
    $ssrs.RSServerUrl = $ssrsURL
    $ssrs.AuthenticationType = $authType

    # Execute update functions to commit new configuration
    $ssrs.update() | Out-Null
    $ssrs.provision() | Out-Null

    # Provide the SQL Server Reporting Services service account with SharePoint access
    Get-SPWebApplication -IncludeCentralAdministration | %{$_.GrantAccessToProcessIdentity($sqlServiceAcct)}

    Write-Log $logFile "Successfully configured SharePoint 2010 Report Server Integration" $lvlInfo
}
catch
{
    Write-Log $logFile $Error[0] $lvlError
}



********************
PowerShell - Report Server Integration - Part 1
PowerShell - Report Server Integration - Part 2
PowerShell - Report Server Integration - Part 4
********************

No comments:

Post a Comment