MSSQL Reporting Services: Seed Data Source

Microsoft.SQLServer.ReportingServices.Windows.DataSource.LocalSeed (DataSourceModuleType)

Microsoft SQL Server Reporting Services Seed Data Source.

Element properties:

TypeDataSourceModuleType
IsolationAny
AccessibilityInternal
RunAsDefault
OutputTypeSystem.Discovery.Data

Member Modules:

ID Module Type TypeId RunAs 
DS DataSource System.Discovery.Scheduler Default
Script ProbeAction Microsoft.Windows.PowerShellDiscoveryProbe Default

Overrideable Parameters:

IDParameterTypeSelectorDisplay NameDescription
IntervalSecondsint$Config/IntervalSeconds$Interval (seconds)The recurring interval of time in seconds in which to run the workflow.
SyncTimestring$Config/SyncTime$Synchronization TimeThe synchronization time specified by using a 24-hour format. May be omitted.
TimeoutSecondsint$Config/TimeoutSeconds$Timeout (seconds)Specifies the time the workflow is allowed to run before being closed and marked as failed.

Source Code:

<DataSourceModuleType ID="Microsoft.SQLServer.ReportingServices.Windows.DataSource.LocalSeed" Accessibility="Internal">
<Configuration>
<xsd:element xmlns:xsd="http://www.w3.org/2001/XMLSchema" name="PrincipalName" type="xsd:string"/>
<xsd:element xmlns:xsd="http://www.w3.org/2001/XMLSchema" name="TimeoutSeconds" type="xsd:integer"/>
<xsd:element xmlns:xsd="http://www.w3.org/2001/XMLSchema" name="IntervalSeconds" type="xsd:integer"/>
<xsd:element xmlns:xsd="http://www.w3.org/2001/XMLSchema" name="SyncTime" type="xsd:string"/>
</Configuration>
<OverrideableParameters>
<OverrideableParameter ID="IntervalSeconds" ParameterType="int" Selector="$Config/IntervalSeconds$"/>
<OverrideableParameter ID="SyncTime" ParameterType="string" Selector="$Config/SyncTime$"/>
<OverrideableParameter ID="TimeoutSeconds" ParameterType="int" Selector="$Config/TimeoutSeconds$"/>
</OverrideableParameters>
<ModuleImplementation>
<Composite>
<MemberModules>
<DataSource ID="DS" TypeID="System!System.Discovery.Scheduler">
<Scheduler>
<SimpleReccuringSchedule>
<Interval>$Config/IntervalSeconds$</Interval>
<SyncTime>$Config/SyncTime$</SyncTime>
</SimpleReccuringSchedule>
<ExcludeDates/>
</Scheduler>
</DataSource>
<ProbeAction ID="Script" TypeID="Windows!Microsoft.Windows.PowerShellDiscoveryProbe">
<ScriptName>DiscoverLocalSeed.ps1</ScriptName>
<ScriptBody><Script>param($principalName, $MapElement, $TargetID)

$MINIMAL_RS_MAJOR_VERSION = 11

$ErrorActionPreference = 'Stop'

$api = New-Object -ComObject "MOM.ScriptAPI"
$discoveryData = $api.CreateDiscoveryData(0, $MapElement, $TargetID)

$computerNameData = Get-ItemProperty 'HKLM:\SYSTEM\CurrentControlSet\Services\Tcpip\Parameters' -ErrorAction Stop
$discoveredName = $computerNameData.Hostname

if(![string]::IsNullOrEmpty($computerNameData.Domain)){
$discoveredName = "$($computerNameData.Hostname).$($computerNameData.Domain)"
}

if($principalName -ne $discoveredName){
$discoveryData
exit
}

$rsExists = $false

$rsInstancesPath = 'HKLM:SOFTWARE\Microsoft\Microsoft SQL Server\Instance Names\RS'
$instanceVersionPath = 'HKLM:SOFTWARE\Microsoft\Microsoft SQL Server\{0}\MSSQLServer\CurrentVersion'

if(Test-Path $rsInstancesPath){
$versions = Get-Item $rsInstancesPath |`
Select -ExpandProperty 'Property' |`
%{ (Get-ItemProperty -Path $rsInstancesPath -Name $_).$_ } |`
%{
$path = $instanceVersionPath -f $_
if (Test-Path $path){
$regVal = Get-ItemProperty -Path $path -Name CurrentVersion -ErrorAction SilentlyContinue
if($regVal -ne $null) {
$regVal.CurrentVersion
}
}
} |`
?{ $_ -is [string] -and ![string]::IsNullOrEmpty($_) } |`
%{ [int]$_.Split('.')[0] } |`
?{ $_ -ge $MINIMAL_RS_MAJOR_VERSION }

$rsExists = $versions.Length -gt 0
}

if($rsExists){
$targetObj = $discoveryData.CreateClassInstance("$MPElement[Name='Microsoft.SQLServer.ReportingServices.Windows.LocalSeed']$")

$targetObj.AddProperty("$MPElement[Name='Windows!Microsoft.Windows.Computer']/PrincipalName$", $principalName)
$targetObj.AddProperty("$MPElement[Name='System!System.Entity']/DisplayName$", $principalName)

$discoveryData.AddInstance($targetObj)

$eventLogTargetObj = $discoveryData.CreateClassInstance("$MPElement[Name='RsCore!Microsoft.SQLServer.ReportingServices.Core.EventLogCollectionTarget']$")
$eventLogTargetObj.AddProperty("$MPElement[Name='Windows!Microsoft.Windows.Computer']/PrincipalName$", $principalName)
$eventLogTargetObj.AddProperty("$MPElement[Name='System!System.Entity']/DisplayName$", $principalName)

$discoveryData.AddInstance($eventLogTargetObj)
}

$discoveryData</Script></ScriptBody>
<SnapIns/>
<Parameters>
<Parameter>
<Name>MapElement</Name>
<Value>$MPElement$</Value>
</Parameter>
<Parameter>
<Name>TargetID</Name>
<Value>$Target/Id$</Value>
</Parameter>
<Parameter>
<Name>PrincipalName</Name>
<Value>$Config/PrincipalName$</Value>
</Parameter>
</Parameters>
<TimeoutSeconds>$Config/TimeoutSeconds$</TimeoutSeconds>
<StrictErrorHandling>true</StrictErrorHandling>
</ProbeAction>
</MemberModules>
<Composition>
<Node ID="Script">
<Node ID="DS"/>
</Node>
</Composition>
</Composite>
</ModuleImplementation>
<OutputType>System!System.Discovery.Data</OutputType>
</DataSourceModuleType>