Skip to content

Commit 9661dbd

Browse files
committed
Add parameter SuppressRestart
1 parent d362529 commit 9661dbd

File tree

2 files changed

+29
-3
lines changed

2 files changed

+29
-3
lines changed

source/Private/Invoke-ReportServerSetupAction.ps1

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,10 @@
5050
Reporting Services: %ProgramFiles%\Microsoft SQL Server Reporting Services
5151
PI Report Server: %ProgramFiles%\Microsoft Power BI Report Server
5252
53+
.PARAMETER SuppressRestart
54+
Suppresses the restart of the computer after the installation is finished.
55+
By default the computer is restarted after the installation is finished.
56+
5357
.PARAMETER Timeout
5458
Specifies how long to wait for the setup process to finish. Default value
5559
is `7200` seconds (2 hours). If the setup process does not finish before
@@ -166,6 +170,10 @@ function Invoke-ReportServerSetupAction
166170
[System.String]
167171
$InstallFolder,
168172

173+
[Parameter()]
174+
[System.Management.Automation.SwitchParameter]
175+
$SuppressRestart,
176+
169177
[Parameter()]
170178
[System.UInt32]
171179
$Timeout = 7200,
@@ -242,6 +250,11 @@ function Invoke-ReportServerSetupAction
242250
$setupArgument += ' /InstallFolder="{0}"' -f $InstallFolder
243251
}
244252

253+
if ($SuppressRestart.IsPresent)
254+
{
255+
$setupArgument += ' /norestart'
256+
}
257+
245258
$verboseSetupArgument = $setupArgument
246259

247260
# Sensitive values.

tests/Unit/Private/Invoke-ReportServerSetupAction.Tests.ps1

Lines changed: 16 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -65,17 +65,17 @@ Describe 'Invoke-ReportServerSetupAction' -Tag 'Private' {
6565
@{
6666
MockParameterSetName = 'Install'
6767
# cSpell: disable-next
68-
MockExpectedParameters = '-Install -AcceptLicensingTerms -MediaPath <string> [-ProductKey <string>] [-EditionUpgrade] [-Edition <string>] [-LogPath <string>] [-InstallFolder <string>] [-Timeout <uint>] [-Force] [-WhatIf] [-Confirm] [<CommonParameters>]'
68+
MockExpectedParameters = '-Install -AcceptLicensingTerms -MediaPath <string> [-ProductKey <string>] [-EditionUpgrade] [-Edition <string>] [-LogPath <string>] [-InstallFolder <string>] [-SuppressRestart] [-Timeout <uint>] [-Force] [-WhatIf] [-Confirm] [<CommonParameters>]'
6969
}
7070
@{
7171
MockParameterSetName = 'Uninstall'
7272
# cSpell: disable-next
73-
MockExpectedParameters = '-Uninstall -MediaPath <string> [-LogPath <string>] [-Timeout <uint>] [-Force] [-WhatIf] [-Confirm] [<CommonParameters>]'
73+
MockExpectedParameters = '-Uninstall -MediaPath <string> [-LogPath <string>] [-SuppressRestart] [-Timeout <uint>] [-Force] [-WhatIf] [-Confirm] [<CommonParameters>]'
7474
}
7575
@{
7676
MockParameterSetName = 'Repair'
7777
# cSpell: disable-next
78-
MockExpectedParameters = '-Repair -AcceptLicensingTerms -MediaPath <string> [-ProductKey <string>] [-EditionUpgrade] [-Edition <string>] [-LogPath <string>] [-InstallFolder <string>] [-Timeout <uint>] [-Force] [-WhatIf] [-Confirm] [<CommonParameters>]'
78+
MockExpectedParameters = '-Repair -AcceptLicensingTerms -MediaPath <string> [-ProductKey <string>] [-EditionUpgrade] [-Edition <string>] [-LogPath <string>] [-InstallFolder <string>] [-SuppressRestart] [-Timeout <uint>] [-Force] [-WhatIf] [-Confirm] [<CommonParameters>]'
7979
}
8080
) {
8181
InModuleScope -Parameters $_ -ScriptBlock {
@@ -231,8 +231,17 @@ Describe 'Invoke-ReportServerSetupAction' -Tag 'Private' {
231231
MockParameterValue = 'C:\Program Files\ReportServer'
232232
MockExpectedRegEx = '\/InstallFolder="C:\\Program Files\\ReportServer"'
233233
}
234+
@{
235+
MockParameterName = 'SuppressRestart'
236+
MockParameterValue = $true
237+
MockExpectedRegEx = '\/norestart'
238+
}
234239
) {
235240
BeforeAll {
241+
Mock -CommandName Test-Path -MockWith {
242+
return $true
243+
}
244+
236245
Mock -CommandName Start-SqlSetupProcess -MockWith {
237246
return 0
238247
} -RemoveParameterValidation 'FilePath'
@@ -570,6 +579,10 @@ Describe 'Invoke-ReportServerSetupAction' -Tag 'Private' {
570579
}
571580
) {
572581
BeforeAll {
582+
Mock -CommandName Test-Path -MockWith {
583+
return $true
584+
}
585+
573586
Mock -CommandName Start-SqlSetupProcess -MockWith {
574587
return 0
575588
} -RemoveParameterValidation 'FilePath'

0 commit comments

Comments
 (0)