Skip to content

Commit 1e0518a

Browse files
authored
Add additional Report Server commands (#2406)
1 parent 71f4c98 commit 1e0518a

16 files changed

+1700
-175
lines changed

.vscode/settings.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -109,7 +109,8 @@
109109
"hotfixes",
110110
"checkpointing",
111111
"HRESULT",
112-
"RSDB"
112+
"RSDB",
113+
"RSIP"
113114
],
114115
"cSpell.ignorePaths": [
115116
".git"

CHANGELOG.md

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,10 @@ 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. Supports filtering
32+
by date range, user name, report path, and maximum rows. Includes connection
33+
parameters **Credential**, **LoginType**, **Encrypt**, and **StatementTimeout**.
3034
- Added public command `Test-SqlDscRSAccessible` to verify that SQL Server
3135
Reporting Services or Power BI Report Server web sites are accessible.
3236
Supports both CIM configuration input (with dynamic `-Site` parameter) and
@@ -233,6 +237,11 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
233237
by calling the `InitializeReportServer` CIM method. Used to complete initial
234238
configuration after database and URL setup
235239
([issue #2014](https://github.com/dsccommunity/SqlServerDsc/issues/2014)).
240+
- Added public command `Get-SqlDscRSIPAddress` to list IP addresses available
241+
for URL reservations. Wraps the `ListIPAddresses` CIM method.
242+
- Added public command `Get-SqlDscRSDatabaseInstallation` to determine whether
243+
a specific report server database is a Reporting Services database. Wraps
244+
the `ListReportServersInDatabase` CIM method.
236245
- Added public command `Request-SqlDscRSDatabaseUpgradeScript` to generate a
237246
T-SQL script for upgrading the report server database schema. Wraps the
238247
`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: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
<#
2+
.SYNOPSIS
3+
Represents an IP address entry returned by the ListIPAddresses CIM method.
4+
5+
.DESCRIPTION
6+
This class represents an IP address available on the report server machine,
7+
including the IP version (V4 or V6) and whether it is DHCP-enabled.
8+
9+
.PARAMETER IPAddress
10+
The IP address string.
11+
12+
.PARAMETER IPVersion
13+
The version of the IP address. Values are 'V4' for IPv4 or 'V6' for IPv6.
14+
15+
.PARAMETER IsDhcpEnabled
16+
Indicates whether the IP address is DHCP-enabled. If true, the IP address
17+
is dynamic and should not be used for TLS bindings.
18+
19+
.EXAMPLE
20+
[ReportServerIPAddress]::new()
21+
22+
Creates a new empty ReportServerIPAddress instance.
23+
24+
.EXAMPLE
25+
$ipAddress = [ReportServerIPAddress]::new()
26+
$ipAddress.IPAddress = '192.168.1.1'
27+
$ipAddress.IPVersion = 'V4'
28+
$ipAddress.IsDhcpEnabled = $false
29+
30+
Creates a new ReportServerIPAddress instance with property values.
31+
#>
32+
class ReportServerIPAddress
33+
{
34+
[System.String]
35+
$IPAddress
36+
37+
[System.String]
38+
$IPVersion
39+
40+
[System.Boolean]
41+
$IsDhcpEnabled
42+
43+
ReportServerIPAddress()
44+
{
45+
}
46+
}
Lines changed: 112 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,112 @@
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 CIM/WMI provider method `ListReportServersInDatabase`
47+
using `Invoke-RsCimMethod`.
48+
49+
.LINK
50+
https://docs.microsoft.com/en-us/sql/reporting-services/wmi-provider-library-reference/configurationsetting-method-listreportserversindatabase
51+
#>
52+
function Get-SqlDscRSDatabaseInstallation
53+
{
54+
[System.Diagnostics.CodeAnalysis.SuppressMessageAttribute('UseSyntacticallyCorrectExamples', '', Justification = 'Because the examples use pipeline input the rule cannot validate.')]
55+
[CmdletBinding()]
56+
[OutputType([System.Management.Automation.PSCustomObject])]
57+
param
58+
(
59+
[Parameter(Mandatory = $true, ValueFromPipeline = $true)]
60+
[System.Object]
61+
$Configuration
62+
)
63+
64+
process
65+
{
66+
$instanceName = $Configuration.InstanceName
67+
68+
Write-Verbose -Message ($script:localizedData.Get_SqlDscRSDatabaseInstallation_Getting -f $instanceName)
69+
70+
$invokeRsCimMethodParameters = @{
71+
CimInstance = $Configuration
72+
MethodName = 'ListReportServersInDatabase'
73+
}
74+
75+
try
76+
{
77+
$result = Invoke-RsCimMethod @invokeRsCimMethodParameters -ErrorAction 'Stop'
78+
79+
<#
80+
The WMI method returns:
81+
- Length: Number of entries in the arrays
82+
- InstallationID: Array of installation IDs
83+
- MachineName: Array of machine names
84+
- InstanceName: Array of instance names
85+
- IsInitialized: Array of initialization states
86+
#>
87+
if ($result.Length -gt 0)
88+
{
89+
for ($i = 0; $i -lt $result.Length; $i++)
90+
{
91+
[PSCustomObject] @{
92+
InstallationID = $result.InstallationIDs[$i]
93+
MachineName = $result.MachineNames[$i]
94+
InstanceName = $result.InstanceNames[$i]
95+
IsInitialized = $result.IsInitialized[$i]
96+
}
97+
}
98+
}
99+
}
100+
catch
101+
{
102+
$PSCmdlet.ThrowTerminatingError(
103+
[System.Management.Automation.ErrorRecord]::new(
104+
($script:localizedData.Get_SqlDscRSDatabaseInstallation_FailedToGet -f $instanceName, $_.Exception.Message),
105+
'GSRSDI0001',
106+
[System.Management.Automation.ErrorCategory]::InvalidOperation,
107+
$Configuration
108+
)
109+
)
110+
}
111+
}
112+
}

0 commit comments

Comments
 (0)