Wednesday, March 21, 2012

PowerShell - Report Server Integration - Part 1

I have SQL Server 2008 (SS2008) and SharePoint 2010 (SP2010).  They are ingrained in a Virtual Machine (VM) template.  I've already had PowerShell (PS) scripts that run against these sysprep'd software applications.  Base configuration has occurred.  Now I want a PS script to establish the Report Server Integration feature within SP2010.

In order to accomplish this, I have to configure Reporting Services within SS2008, Report Server Integration in SP2010, and then activate the features for all existing site collections within SP2010.

The next several posts will describe the break out of each part of the script.  Below is a note about header information and the variables I used throughout the script code you'll see in future posts.

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

PowerShell Snapins needed.  The use of IF blocks is because my script is daisy chained with others, and I don't know what has been previously loaded, and what still needs to be.

# Add Sql Server cmdlets references
if((Get-PSSnapin | Where {$_.Name -eq "SqlServerCmdletSnapin100"}) -eq $null)
{ Add-PSSnapin SqlServerCmdletSnapin100; }
if((Get-PSSnapin | Where {$_.Name -eq "SqlServerProviderSnapin100"}) -eq $null)
{ Add-PSSnapin SqlServerProviderSnapin100; }

# Add SharePoint cmdlets reference
if((Get-PSSnapin | Where {$_.Name -eq "Microsoft.SharePoint.PowerShell"}) -eq $null)
{ Add-PSSnapin Microsoft.SharePoint.PowerShell; }


The variety of local variables I use through out the scripts are:

# Capture the current directory where the script is executing from
$currentLocation = Get-Location

# Capture the name of the computer.
$serverName = $env:computername

# Load the XML configuration file
$config = [xml](Get-Content $args[0]) 

# Define logging variables
$lvlInfo = 0
$lvlWarn = 1
$lvlError = 2

# Get the log file fully qualified path and name.
$logFile = $config.Configuration.Log.Path

# Get the section with configuration for Reporting Services
$rsCfg = $config.Configuration.ReportingServices

$instName = $rsCfg.InstanceName     # Server Instance Name
$reportServer = $rsCfg.ReportServer.DatabaseName    # Name of new Report Server database
$lcid = [int]$rsCfg.ReportServer.Lcid    # Language definition id.  1033 for english


#  Administrative account with permission to execute changes in SharePoint
$sqlUser = $rsCfg.Administrator.Username
$sqlPwd = $rsCfg.Administrator.Password

$sqlServiceAcct = $rsCfg.ReportServer.ServiceAccount    # Service account to associate with Sql Server reporting services
$credType = [int]$rsCfg.ReportServer.CredentialType     # CredentialsType  (0 - Windows; 1 - SQL Server; 2 - Service)
$authType = $rsCfg.AuthenticationType    # How SharePoint will connect with Sql Server Report Server (Windows, Trusted)
$features = $rsCfg.Feature    # Features within SharePoint site collections that will need activating for Reporting Services to work  (Reporting, ReportServer)

$dbServer = "$serverName\$instName"    # Server and instance identifier for use with SQL Server Report Server Configuration
$ssrsURL = "http://$serverName/$($reportServer)_$instName"    # The URL of the report server used by SharePoint for integration.

No comments:

Post a Comment