Skip to content

Commit f9eda7b

Browse files
authored
Add PassThru parameter to Install, Uninstall and Repair commands (#2091)
- `Install-SqlDscReportingService` - Add `PassThru` parameter to return exit code. - `Install-SqlDscBIReportServer` - Add `PassThru` parameter to return exit code. - `Repair-SqlDscReportingService` - Add `PassThru` parameter to return exit code. - `Repair-SqlDscBIReportServer` - Add `PassThru` parameter to return exit code. - `Uninstall-SqlDscReportingService` - Add `PassThru` parameter to return exit code. - `Uninstall-SqlDscBIReportServer` - Add `PassThru` parameter to return exit code.
1 parent 37b433c commit f9eda7b

15 files changed

+405
-30
lines changed

CHANGELOG.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,18 +20,24 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
2020
- Add additional properties to `Get-SqlDscRSSetupConfiguration` output.
2121
- `Install-SqlDscReportingService` to install SQL Server Reporting Services
2222
([issue #2010](https://github.com/dsccommunity/SqlServerDsc/issues/2010)).
23+
- Add `PassThru` parameter to return exit code.
2324
- `Install-SqlDscBIReportServer` to install SQL Server BI Report Server.
2425
([issue #2010](https://github.com/dsccommunity/SqlServerDsc/issues/2010)).
26+
- Add `PassThru` parameter to return exit code.
2527
- `Repair-SqlDscReportingService` to repair an already installed SQL Server
2628
Reporting Services ([issue #2064](https://github.com/dsccommunity/SqlServerDsc/issues/2064)).
29+
- Add `PassThru` parameter to return exit code.
2730
- `Repair-SqlDscBIReportServer` to repair an already installed SQL Server
2831
BI Report Server ([issue #2064](https://github.com/dsccommunity/SqlServerDsc/issues/2064)).
32+
- Add `PassThru` parameter to return exit code.
2933
- `Test-SqlDscRSInstalled` to test whether an instance is installed or not
3034
([issue #2078](https://github.com/dsccommunity/SqlServerDsc/issues/2078)).
3135
- `Uninstall-SqlDscReportingService` to uninstall SQL Server Reporting
3236
Services ([issue #2065](https://github.com/dsccommunity/SqlServerDsc/issues/2065)).
37+
- Add `PassThru` parameter to return exit code.
3338
- `Uninstall-SqlDscBIReportServer` to uninstall SQL Server BI Report Server
3439
([issue #2065](https://github.com/dsccommunity/SqlServerDsc/issues/2065)).
40+
- Add `PassThru` parameter to return exit code.
3541
- Private function:
3642
- `Invoke-ReportServerSetupAction` to run setup actions for Reporting
3743
Services and Power BI Report Server.

source/Private/Invoke-ReportServerSetupAction.ps1

Lines changed: 21 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -63,12 +63,16 @@
6363
If specified the command will not ask for confirmation. Same as if Confirm:$false
6464
is used.
6565
66+
.PARAMETER PassThru
67+
If specified the command will return the setup process exit code.
68+
6669
.LINK
6770
https://learn.microsoft.com/en-us/power-bi/report-server/install-report-server
6871
https://learn.microsoft.com/en-us/sql/reporting-services/install-windows/install-reporting-services
6972
7073
.OUTPUTS
71-
None.
74+
When PassThru is specified the function will return the setup process exit
75+
code as System.Int32. Otherwise, the function does not generate any output.
7276
7377
.EXAMPLE
7478
Invoke-ReportServerSetupAction -Install -AcceptLicensingTerms -MediaPath 'E:\SQLServerReportingServices.exe'
@@ -99,11 +103,16 @@
99103
Invoke-ReportServerSetupAction -Uninstall -MediaPath 'E:\SQLServerReportingServices.exe' -Force
100104
101105
Uninstalls SQL Server Reporting Services without prompting for confirmation.
106+
107+
.EXAMPLE
108+
$exitCode = Invoke-ReportServerSetupAction -Install -AcceptLicensingTerms -MediaPath 'E:\SQLServerReportingServices.exe' -PassThru
109+
110+
Installs SQL Server Reporting Services and returns the setup process exit code.
102111
#>
103112
function Invoke-ReportServerSetupAction
104113
{
105114
[CmdletBinding(SupportsShouldProcess = $true, ConfirmImpact = 'High')]
106-
[OutputType()]
115+
[OutputType([System.Int32])]
107116
param
108117
(
109118
[Parameter(ParameterSetName = 'Install', Mandatory = $true)]
@@ -180,7 +189,11 @@ function Invoke-ReportServerSetupAction
180189

181190
[Parameter()]
182191
[System.Management.Automation.SwitchParameter]
183-
$Force
192+
$Force,
193+
194+
[Parameter()]
195+
[System.Management.Automation.SwitchParameter]
196+
$PassThru
184197
)
185198

186199
if ($Force.IsPresent -and -not $Confirm)
@@ -328,5 +341,10 @@ function Invoke-ReportServerSetupAction
328341
'{0} {1}' -f $setupExitMessage, ($script:localizedData.SetupAction_SetupSuccessful)
329342
)
330343
}
344+
345+
if ($PassThru.IsPresent)
346+
{
347+
return $processExitCode
348+
}
331349
}
332350
}

source/Public/Install-SqlDscBIReportServer.ps1

Lines changed: 24 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,13 @@
5252
If specified the command will not ask for confirmation. Same as if Confirm:$false
5353
is used.
5454
55+
.PARAMETER PassThru
56+
If specified the command will return the setup process exit code.
57+
58+
.OUTPUTS
59+
When PassThru is specified the function will return the setup process exit
60+
code as System.Int32. Otherwise, the function does not generate any output.
61+
5562
.EXAMPLE
5663
Install-SqlDscBIReportServer -AcceptLicensingTerms -MediaPath 'E:\PowerBIReportServer.exe'
5764
@@ -71,12 +78,17 @@
7178
Install-SqlDscBIReportServer -AcceptLicensingTerms -MediaPath 'E:\PowerBIReportServer.exe' -ProductKey '12345-12345-12345-12345-12345' -EditionUpgrade -LogPath 'C:\Logs\PowerBIReportServer_Install.log'
7279
7380
Installs Power BI Report Server and upgrades the edition using a product key. Also specifies a custom log path.
81+
82+
.EXAMPLE
83+
$exitCode = Install-SqlDscBIReportServer -AcceptLicensingTerms -MediaPath 'E:\PowerBIReportServer.exe' -PassThru
84+
85+
Installs Power BI Report Server with default settings and returns the setup exit code.
7486
#>
7587
function Install-SqlDscBIReportServer
7688
{
7789
[System.Diagnostics.CodeAnalysis.SuppressMessageAttribute('PSShouldProcess', '', Justification = 'Because ShouldProcess is used in Invoke-SetupAction')]
7890
[CmdletBinding(SupportsShouldProcess = $true, ConfirmImpact = 'High')]
79-
[OutputType()]
91+
[OutputType([System.Int32])]
8092
param
8193
(
8294
[Parameter(Mandatory = $true)]
@@ -118,8 +130,17 @@ function Install-SqlDscBIReportServer
118130

119131
[Parameter()]
120132
[System.Management.Automation.SwitchParameter]
121-
$Force
133+
$Force,
134+
135+
[Parameter()]
136+
[System.Management.Automation.SwitchParameter]
137+
$PassThru
122138
)
123139

124-
Invoke-ReportServerSetupAction -Install @PSBoundParameters
140+
$exitCode = Invoke-ReportServerSetupAction -Install @PSBoundParameters
141+
142+
if ($PassThru.IsPresent)
143+
{
144+
return $exitCode
145+
}
125146
}

source/Public/Install-SqlDscReportingService.ps1

Lines changed: 24 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,13 @@
5353
If specified the command will not ask for confirmation. Same as if Confirm:$false
5454
is used.
5555
56+
.PARAMETER PassThru
57+
If specified the command will return the setup process exit code.
58+
59+
.OUTPUTS
60+
When PassThru is specified the function will return the setup process exit
61+
code as System.Int32. Otherwise, the function does not generate any output.
62+
5663
.EXAMPLE
5764
Install-SqlDscReportingService -AcceptLicensingTerms -MediaPath 'E:\SQLServerReportingServices.exe'
5865
@@ -73,12 +80,17 @@
7380
7481
Installs SQL Server Reporting Services and upgrades the edition using a
7582
product key. Also specifies a custom log path.
83+
84+
.EXAMPLE
85+
$exitCode = Install-SqlDscReportingService -AcceptLicensingTerms -MediaPath 'E:\SQLServerReportingServices.exe' -PassThru
86+
87+
Installs SQL Server Reporting Services with default settings and returns the setup exit code.
7688
#>
7789
function Install-SqlDscReportingService
7890
{
7991
[System.Diagnostics.CodeAnalysis.SuppressMessageAttribute('PSShouldProcess', '', Justification = 'Because ShouldProcess is used in Invoke-SetupAction')]
8092
[CmdletBinding(SupportsShouldProcess = $true, ConfirmImpact = 'High')]
81-
[OutputType()]
93+
[OutputType([System.Int32])]
8294
param
8395
(
8496
[Parameter(Mandatory = $true)]
@@ -120,8 +132,17 @@ function Install-SqlDscReportingService
120132

121133
[Parameter()]
122134
[System.Management.Automation.SwitchParameter]
123-
$Force
135+
$Force,
136+
137+
[Parameter()]
138+
[System.Management.Automation.SwitchParameter]
139+
$PassThru
124140
)
125141

126-
Invoke-ReportServerSetupAction -Install @PSBoundParameters
142+
$exitCode = Invoke-ReportServerSetupAction -Install @PSBoundParameters
143+
144+
if ($PassThru.IsPresent)
145+
{
146+
return $exitCode
147+
}
127148
}

source/Public/Repair-SqlDscBIReportServer.ps1

Lines changed: 24 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,13 @@
5252
If specified the command will not ask for confirmation. Same as if Confirm:$false
5353
is used.
5454
55+
.PARAMETER PassThru
56+
If specified the command will return the setup process exit code.
57+
58+
.OUTPUTS
59+
When PassThru is specified the function will return the setup process exit
60+
code as System.Int32. Otherwise, the function does not generate any output.
61+
5562
.EXAMPLE
5663
Repair-SqlDscBIReportServer -AcceptLicensingTerms -MediaPath 'E:\PowerBIReportServer.exe'
5764
@@ -67,12 +74,17 @@
6774
Repair-SqlDscBIReportServer -AcceptLicensingTerms -MediaPath 'E:\PowerBIReportServer.exe' -LogPath 'C:\Logs\PowerBIReportServer_Repair.log'
6875
6976
Repairs Power BI Report Server and specifies a custom log path.
77+
78+
.EXAMPLE
79+
$exitCode = Repair-SqlDscBIReportServer -AcceptLicensingTerms -MediaPath 'E:\PowerBIReportServer.exe' -PassThru
80+
81+
Repairs Power BI Report Server with default settings and returns the setup exit code.
7082
#>
7183
function Repair-SqlDscBIReportServer
7284
{
7385
[System.Diagnostics.CodeAnalysis.SuppressMessageAttribute('PSShouldProcess', '', Justification = 'Because ShouldProcess is used in Invoke-SetupAction')]
7486
[CmdletBinding(SupportsShouldProcess = $true, ConfirmImpact = 'High')]
75-
[OutputType()]
87+
[OutputType([System.Int32])]
7688
param
7789
(
7890
[Parameter(Mandatory = $true)]
@@ -114,8 +126,17 @@ function Repair-SqlDscBIReportServer
114126

115127
[Parameter()]
116128
[System.Management.Automation.SwitchParameter]
117-
$Force
129+
$Force,
130+
131+
[Parameter()]
132+
[System.Management.Automation.SwitchParameter]
133+
$PassThru
118134
)
119135

120-
Invoke-ReportServerSetupAction -Repair @PSBoundParameters
136+
$exitCode = Invoke-ReportServerSetupAction -Repair @PSBoundParameters
137+
138+
if ($PassThru.IsPresent)
139+
{
140+
return $exitCode
141+
}
121142
}

source/Public/Repair-SqlDscReportingService.ps1

Lines changed: 24 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,13 @@
5454
If specified the command will not ask for confirmation. Same as if Confirm:$false
5555
is used.
5656
57+
.PARAMETER PassThru
58+
If specified the command will return the setup process exit code.
59+
60+
.OUTPUTS
61+
When PassThru is specified the function will return the setup process exit
62+
code as System.Int32. Otherwise, the function does not generate any output.
63+
5764
.EXAMPLE
5865
Repair-SqlDscReportingService -AcceptLicensingTerms -MediaPath 'E:\SQLServerReportingServices.exe'
5966
@@ -69,12 +76,17 @@
6976
Repair-SqlDscReportingService -AcceptLicensingTerms -MediaPath 'E:\PowerBIReportServer.exe' -LogPath 'C:\Logs\PowerBIReportServer_Repair.log'
7077
7178
Repairs Power BI Report Server and specifies a custom log path.
79+
80+
.EXAMPLE
81+
$exitCode = Repair-SqlDscReportingService -AcceptLicensingTerms -MediaPath 'E:\SQLServerReportingServices.exe' -PassThru
82+
83+
Repairs SQL Server Reporting Services with default settings and returns the setup exit code.
7284
#>
7385
function Repair-SqlDscReportingService
7486
{
7587
[System.Diagnostics.CodeAnalysis.SuppressMessageAttribute('PSShouldProcess', '', Justification = 'Because ShouldProcess is used in Invoke-SetupAction')]
7688
[CmdletBinding(SupportsShouldProcess = $true, ConfirmImpact = 'High')]
77-
[OutputType()]
89+
[OutputType([System.Int32])]
7890
param
7991
(
8092
[Parameter(Mandatory = $true)]
@@ -116,8 +128,17 @@ function Repair-SqlDscReportingService
116128

117129
[Parameter()]
118130
[System.Management.Automation.SwitchParameter]
119-
$Force
131+
$Force,
132+
133+
[Parameter()]
134+
[System.Management.Automation.SwitchParameter]
135+
$PassThru
120136
)
121137

122-
Invoke-ReportServerSetupAction -Repair @PSBoundParameters
138+
$exitCode = Invoke-ReportServerSetupAction -Repair @PSBoundParameters
139+
140+
if ($PassThru.IsPresent)
141+
{
142+
return $exitCode
143+
}
123144
}

source/Public/Uninstall-SqlDscBIReportServer.ps1

Lines changed: 24 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,13 @@
2626
If specified the command will not ask for confirmation. Same as if Confirm:$false
2727
is used.
2828
29+
.PARAMETER PassThru
30+
If specified the command will return the setup process exit code.
31+
32+
.OUTPUTS
33+
When PassThru is specified the function will return the setup process exit
34+
code as System.Int32. Otherwise, the function does not generate any output.
35+
2936
.EXAMPLE
3037
Uninstall-SqlDscBIReportServer -MediaPath 'E:\PowerBIReportServer.exe'
3138
@@ -40,12 +47,17 @@
4047
Uninstall-SqlDscBIReportServer -MediaPath 'E:\PowerBIReportServer.exe' -Force
4148
4249
Uninstalls Power BI Report Server without prompting for confirmation.
50+
51+
.EXAMPLE
52+
$exitCode = Uninstall-SqlDscBIReportServer -MediaPath 'E:\PowerBIReportServer.exe' -PassThru
53+
54+
Uninstalls Power BI Report Server and returns the setup exit code.
4355
#>
4456
function Uninstall-SqlDscBIReportServer
4557
{
4658
[System.Diagnostics.CodeAnalysis.SuppressMessageAttribute('PSShouldProcess', '', Justification = 'Because ShouldProcess is used in Invoke-SetupAction')]
4759
[CmdletBinding(SupportsShouldProcess = $true, ConfirmImpact = 'High')]
48-
[OutputType()]
60+
[OutputType([System.Int32])]
4961
param
5062
(
5163
[Parameter(Mandatory = $true)]
@@ -66,8 +78,17 @@ function Uninstall-SqlDscBIReportServer
6678

6779
[Parameter()]
6880
[System.Management.Automation.SwitchParameter]
69-
$Force
81+
$Force,
82+
83+
[Parameter()]
84+
[System.Management.Automation.SwitchParameter]
85+
$PassThru
7086
)
7187

72-
Invoke-ReportServerSetupAction -Uninstall @PSBoundParameters
88+
$exitCode = Invoke-ReportServerSetupAction -Uninstall @PSBoundParameters
89+
90+
if ($PassThru.IsPresent)
91+
{
92+
return $exitCode
93+
}
7394
}

0 commit comments

Comments
 (0)