Skip to content

Commit be94b4f

Browse files
committed
Add additional Report Server commands
1 parent 71f4c98 commit be94b4f

12 files changed

Lines changed: 1661 additions & 0 deletions

CHANGELOG.md

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,11 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
2727
ErrorDumpDirectory from the instance's setup configuration, which can be
2828
used with `Get-ChildItem` and `Get-Content` to access service logs, portal
2929
logs, and memory dumps.
30+
- Added public command `Get-SqlDscRSExecutionLog` to query execution log entries
31+
from the `ExecutionLog3` view in the report server database for SQL Server
32+
Reporting Services or Power BI Report Server. Supports filtering by date
33+
range, user name, report path, and maximum rows. Includes connection parameters
34+
for authentication including Credential, LoginType, Encrypt, and StatementTimeout.
3035
- Added public command `Test-SqlDscRSAccessible` to verify that SQL Server
3136
Reporting Services or Power BI Report Server web sites are accessible.
3237
Supports both CIM configuration input (with dynamic `-Site` parameter) and
@@ -233,6 +238,11 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
233238
by calling the `InitializeReportServer` CIM method. Used to complete initial
234239
configuration after database and URL setup
235240
([issue #2014](https://github.com/dsccommunity/SqlServerDsc/issues/2014)).
241+
- Added public command `Get-SqlDscRSIPAddress` to list IP addresses available
242+
for URL reservations. Wraps the `ListIPAddresses` CIM method.
243+
- Added public command `Get-SqlDscRSDatabaseInstallation` to determine whether
244+
a specific report server database is a Reporting Services database. Wraps
245+
the `ListReportServersInDatabase` CIM method.
236246
- Added public command `Request-SqlDscRSDatabaseUpgradeScript` to generate a
237247
T-SQL script for upgrading the report server database schema. Wraps the
238248
`GenerateDatabaseUpgradeScript` CIM method.

azure-pipelines.yml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -586,6 +586,9 @@ stages:
586586
# Group 5 - Post-initialization validation
587587
'tests/Integration/Commands/Post.Initialization.RS.Integration.Tests.ps1'
588588
'tests/Integration/Commands/Get-SqlDscRSUrl.Integration.Tests.ps1'
589+
'tests/Integration/Commands/Get-SqlDscRSIPAddress.Integration.Tests.ps1'
590+
'tests/Integration/Commands/Get-SqlDscRSDatabaseInstallation.Integration.Tests.ps1'
591+
'tests/Integration/Commands/Get-SqlDscRSExecutionLog.Integration.Tests.ps1'
589592
# Group 6 - Service account change
590593
'tests/Integration/Commands/Set-SqlDscRSServiceAccount.Integration.Tests.ps1'
591594
'tests/Integration/Commands/Get-SqlDscRSServiceAccount.Integration.Tests.ps1'
@@ -683,6 +686,9 @@ stages:
683686
# Group 5 - Post-initialization validation
684687
'tests/Integration/Commands/Post.Initialization.RS.Integration.Tests.ps1'
685688
'tests/Integration/Commands/Get-SqlDscRSUrl.Integration.Tests.ps1'
689+
'tests/Integration/Commands/Get-SqlDscRSIPAddress.Integration.Tests.ps1'
690+
'tests/Integration/Commands/Get-SqlDscRSDatabaseInstallation.Integration.Tests.ps1'
691+
'tests/Integration/Commands/Get-SqlDscRSExecutionLog.Integration.Tests.ps1'
686692
# Group 6 - Service account change
687693
'tests/Integration/Commands/Set-SqlDscRSServiceAccount.Integration.Tests.ps1'
688694
'tests/Integration/Commands/Get-SqlDscRSServiceAccount.Integration.Tests.ps1'
Lines changed: 110 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,110 @@
1+
<#
2+
.SYNOPSIS
3+
Gets the report server installations registered in the database.
4+
5+
.DESCRIPTION
6+
Gets the Reporting Services installations registered in the report
7+
server database by calling the `ListReportServersInDatabase` method
8+
on the `MSReportServer_ConfigurationSetting` CIM instance.
9+
10+
This command returns information about all report server installations
11+
that are configured to use the same report server database, which is
12+
useful in scale-out deployment scenarios.
13+
14+
The configuration CIM instance can be obtained using the
15+
`Get-SqlDscRSConfiguration` command and passed via the pipeline.
16+
17+
.PARAMETER Configuration
18+
Specifies the `MSReportServer_ConfigurationSetting` CIM instance for
19+
the Reporting Services instance. This can be obtained using the
20+
`Get-SqlDscRSConfiguration` command. This parameter accepts pipeline
21+
input.
22+
23+
.EXAMPLE
24+
Get-SqlDscRSConfiguration -InstanceName 'SSRS' | Get-SqlDscRSDatabaseInstallation
25+
26+
Gets all report server installations registered in the database.
27+
28+
.EXAMPLE
29+
$config = Get-SqlDscRSConfiguration -InstanceName 'SSRS'
30+
Get-SqlDscRSDatabaseInstallation -Configuration $config
31+
32+
Gets report server installations using a stored configuration object.
33+
34+
.INPUTS
35+
`Microsoft.Management.Infrastructure.CimInstance`
36+
37+
Accepts MSReportServer_ConfigurationSetting CIM instance via pipeline.
38+
39+
.OUTPUTS
40+
`System.Management.Automation.PSCustomObject`
41+
42+
Returns objects with properties: InstallationID, MachineName,
43+
InstanceName, and IsInitialized.
44+
45+
.NOTES
46+
This command calls the WMI method `ListReportServersInDatabase`.
47+
48+
.LINK
49+
https://docs.microsoft.com/en-us/sql/reporting-services/wmi-provider-library-reference/configurationsetting-method-listreportserversindatabase
50+
#>
51+
function Get-SqlDscRSDatabaseInstallation
52+
{
53+
[System.Diagnostics.CodeAnalysis.SuppressMessageAttribute('UseSyntacticallyCorrectExamples', '', Justification = 'Because the examples use pipeline input the rule cannot validate.')]
54+
[CmdletBinding()]
55+
[OutputType([System.Management.Automation.PSCustomObject])]
56+
param
57+
(
58+
[Parameter(Mandatory = $true, ValueFromPipeline = $true)]
59+
[System.Object]
60+
$Configuration
61+
)
62+
63+
process
64+
{
65+
$instanceName = $Configuration.InstanceName
66+
67+
Write-Verbose -Message ($script:localizedData.Get_SqlDscRSDatabaseInstallation_Getting -f $instanceName)
68+
69+
$invokeRsCimMethodParameters = @{
70+
CimInstance = $Configuration
71+
MethodName = 'ListReportServersInDatabase'
72+
}
73+
74+
try
75+
{
76+
$result = Invoke-RsCimMethod @invokeRsCimMethodParameters -ErrorAction 'Stop'
77+
78+
<#
79+
The WMI method returns multiple parallel arrays:
80+
- InstallationID: Array of installation IDs
81+
- MachineName: Array of machine names
82+
- InstanceName: Array of instance names
83+
- IsInitialized: Array of initialization states
84+
#>
85+
if ($result.InstallationID)
86+
{
87+
for ($i = 0; $i -lt $result.InstallationID.Count; $i++)
88+
{
89+
[PSCustomObject] @{
90+
InstallationID = $result.InstallationID[$i]
91+
MachineName = $result.MachineName[$i]
92+
InstanceName = $result.InstanceName[$i]
93+
IsInitialized = $result.IsInitialized[$i]
94+
}
95+
}
96+
}
97+
}
98+
catch
99+
{
100+
$PSCmdlet.ThrowTerminatingError(
101+
[System.Management.Automation.ErrorRecord]::new(
102+
($script:localizedData.Get_SqlDscRSDatabaseInstallation_FailedToGet -f $instanceName, $_.Exception.Message),
103+
'GSRSDI0001',
104+
[System.Management.Automation.ErrorCategory]::InvalidOperation,
105+
$Configuration
106+
)
107+
)
108+
}
109+
}
110+
}

0 commit comments

Comments
 (0)