forked from dsccommunity/SqlServerDsc
-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathGet-SqlDscRSSetupConfiguration.ps1
More file actions
200 lines (162 loc) · 8.17 KB
/
Get-SqlDscRSSetupConfiguration.ps1
File metadata and controls
200 lines (162 loc) · 8.17 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
<#
.SYNOPSIS
Gets the SQL Server Reporting Services or Power BI Report Server setup
configuration from the Registry.
.DESCRIPTION
Gets the SQL Server Reporting Services and Power BI Report Server setup
configuration information from the Registry. This includes information like
instance name, installation folder, service name, error dump directory,
customer feedback settings, error reporting settings, virtual root, configuration
file path, and various version information of the installed Reporting Services
instance.
When no InstanceName is specified, it returns configuration information for all
installed Reporting Services instances.
.PARAMETER InstanceName
Specifies the instance name to return configuration information for.
If not specified, configuration information for all Reporting Services
and Power BI Report Server instances will be returned.
.EXAMPLE
Get-SqlDscRSSetupConfiguration
Returns configuration information about all SQL Server Reporting Services
and Power BI Report Server instances.
.EXAMPLE
Get-SqlDscRSSetupConfiguration -InstanceName 'SSRS'
Returns configuration information about the SQL Server Reporting Services
instance 'SSRS'.
.EXAMPLE
Get-SqlDscRSSetupConfiguration -InstanceName 'PBIRS'
Returns configuration information about the Power BI Report Server
instance 'PBIRS'.
.INPUTS
None.
.OUTPUTS
`PSCustomObject[]`
Returns an array of custom objects containing Reporting Services configuration
information including instance name, installation folder, service details, version
information, and additional properties.
#>
function Get-SqlDscRSSetupConfiguration
{
[CmdletBinding()]
[OutputType([PSCustomObject[]])]
param
(
[Parameter()]
[System.String]
$InstanceName
)
$reportingServicesInstances = @()
# Get all Reporting Services instances or filter by specified instance name
$getInstalledInstanceParams = @{
ServiceType = 'ReportingServices'
}
if ($PSBoundParameters.ContainsKey('InstanceName'))
{
Write-Verbose -Message ($script:localizedData.Get_SqlDscRSSetupConfiguration_GetSpecificInstance -f $InstanceName)
$getInstalledInstanceParams.InstanceName = $InstanceName
}
else
{
Write-Verbose -Message $script:localizedData.Get_SqlDscRSSetupConfiguration_GetAllInstances
}
$instances = Get-SqlDscInstalledInstance @getInstalledInstanceParams
foreach ($instance in $instances)
{
Write-Verbose -Message ($script:localizedData.Get_SqlDscRSSetupConfiguration_ProcessingInstance -f $instance.InstanceName)
$returnObject = [PSCustomObject]@{
InstanceName = $instance.InstanceName
InstallFolder = $null
ServiceName = $null
ErrorDumpDirectory = $null
CurrentVersion = $null
CustomerFeedback = $null
EnableErrorReporting = $null
ProductVersion = $null
VirtualRootServer = $null
ConfigFilePath = $null
EditionID = $null
EditionName = $null
IsSharePointIntegrated = $null
InstanceId = $instance.InstanceId
}
Write-Verbose -Message ($script:localizedData.Get_SqlDscRSSetupConfiguration_FoundInstance -f $instance.InstanceName)
$getRegistryPropertyValueParameters = @{
ErrorAction = 'SilentlyContinue'
}
# Get values from SSRS\Setup registry key
$getRegistryPropertyValueParameters.Path = 'HKLM:\SOFTWARE\Microsoft\Microsoft SQL Server\{0}\Setup' -f $returnObject.InstanceId
# InstallRootDirectory
$getRegistryPropertyValueParameters.Name = 'InstallRootDirectory'
$returnObject.InstallFolder = Get-RegistryPropertyValue @getRegistryPropertyValueParameters
# Fallback to SQLPath if InstallRootDirectory is not found. This is the case for SQL 2016 and earlier.
if ($null -eq $returnObject.InstallFolder)
{
$getRegistryPropertyValueParameters.Name = 'SQLPath'
$returnObject.InstallFolder = Get-RegistryPropertyValue @getRegistryPropertyValueParameters
if (($null -ne $returnObject.InstallFolder) -and ($returnObject.InstallFolder -notmatch '^[A-Za-z]:\\?$'))
{
$returnObject.InstallFolder = $returnObject.InstallFolder.TrimEnd('\')
}
}
# ServiceName
$getRegistryPropertyValueParameters.Name = 'ServiceName'
$returnObject.ServiceName = Get-RegistryPropertyValue @getRegistryPropertyValueParameters
# RSVirtualRootServer
$getRegistryPropertyValueParameters.Name = 'RSVirtualRootServer'
$returnObject.VirtualRootServer = Get-RegistryPropertyValue @getRegistryPropertyValueParameters
# RsConfigFilePath
$getRegistryPropertyValueParameters.Name = 'RsConfigFilePath'
$returnObject.ConfigFilePath = Get-RegistryPropertyValue @getRegistryPropertyValueParameters
# Get values from SSRS\CPE registry key
$getRegistryPropertyValueParameters.Path = 'HKLM:\SOFTWARE\Microsoft\Microsoft SQL Server\{0}\CPE' -f $returnObject.InstanceId
# ErrorDumpDir
$getRegistryPropertyValueParameters.Name = 'ErrorDumpDir'
$returnObject.ErrorDumpDirectory = Get-RegistryPropertyValue @getRegistryPropertyValueParameters
# CustomerFeedback
$getRegistryPropertyValueParameters.Name = 'CustomerFeedback'
$returnObject.CustomerFeedback = Get-RegistryPropertyValue @getRegistryPropertyValueParameters
# EnableErrorReporting
$getRegistryPropertyValueParameters.Name = 'EnableErrorReporting'
$returnObject.EnableErrorReporting = Get-RegistryPropertyValue @getRegistryPropertyValueParameters
# Get values from SSRS\MSSQLServer\CurrentVersion registry key
$getRegistryPropertyValueParameters.Path = 'HKLM:\SOFTWARE\Microsoft\Microsoft SQL Server\{0}\MSSQLServer\CurrentVersion' -f $returnObject.InstanceId
# CurrentVersion from registry
$getRegistryPropertyValueParameters.Name = 'CurrentVersion'
$returnObject.CurrentVersion = Get-RegistryPropertyValue @getRegistryPropertyValueParameters
# ProductVersion
$getRegistryPropertyValueParameters.Name = 'ProductVersion'
$returnObject.ProductVersion = Get-RegistryPropertyValue @getRegistryPropertyValueParameters
if (-not [System.String]::IsNullOrEmpty($returnObject.CurrentVersion))
{
$reportServerCurrentVersion = [System.Version] $returnObject.CurrentVersion
# Get values from MSReportServer_Instance
$getCimInstanceParameters = @{
Filter = "InstanceId='{0}'" -f $returnObject.InstanceId
Namespace = 'root\Microsoft\SqlServer\ReportServer\RS_{0}\v{1}' -f $instance.InstanceName, $reportServerCurrentVersion.Major
ClassName = 'MSReportServer_Instance'
ErrorAction = 'SilentlyContinue'
}
$msReportServerInstance = Get-CimInstance @getCimInstanceParameters
if ($msReportServerInstance)
{
$returnObject.EditionID = $msReportServerInstance.EditionID
$returnObject.EditionName = $msReportServerInstance.EditionName
$returnObject.IsSharePointIntegrated = $msReportServerInstance.IsSharePointIntegrated
$returnObject.InstanceId = $msReportServerInstance.InstanceId
}
}
$reportingServicesInstances += $returnObject
}
if ($reportingServicesInstances.Count -eq 0)
{
if ($PSBoundParameters.ContainsKey('InstanceName'))
{
Write-Verbose -Message ($script:localizedData.Get_SqlDscRSSetupConfiguration_InstanceNotFound -f $InstanceName)
}
else
{
Write-Verbose -Message $script:localizedData.Get_SqlDscRSSetupConfiguration_NoInstancesFound
}
}
return $reportingServicesInstances
}