Skip to content

Commit 13de1b1

Browse files
committed
Add functions for installing, repairing, and uninstalling Reporting Services
1 parent c4ad039 commit 13de1b1

7 files changed

+833
-0
lines changed

CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,10 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
77

88
### Added
99

10+
- Public commands:
11+
- `Install-SqlDscReportingServices`
12+
- `Install-SqlDscReportingServices`
13+
- `Uninstall-SqlDscReportingServices`
1014
- Private function:
1115
- `Invoke-ReportServerSetupAction`
1216

Lines changed: 127 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,127 @@
1+
<#
2+
.SYNOPSIS
3+
Installs SQL Server Reporting Services or Power BI Report Server.
4+
5+
.DESCRIPTION
6+
Installs SQL Server Reporting Services or Power BI Report Server using
7+
the provided setup executable.
8+
9+
.PARAMETER AcceptLicensingTerms
10+
Required parameter to be able to run unattended install. By specifying this
11+
parameter you acknowledge the acceptance of all license terms and notices for
12+
the specified features, the terms and notices that the setup executable
13+
normally asks for.
14+
15+
.PARAMETER MediaPath
16+
Specifies the path where to find the SQL Server installation media. On this
17+
path the SQL Server setup executable must be found.
18+
19+
.PARAMETER ProductKey
20+
Specifies the product key to use for the installation, e.g. '12345-12345-12345-12345-12345'.
21+
This parameter is mutually exclusive with the parameter Edition.
22+
23+
.PARAMETER EditionUpgrade
24+
Upgrades the edition of the installed product. Requires that either the
25+
ProductKey or the Edition parameter is also assigned. By default no edition
26+
upgrade is performed.
27+
28+
.PARAMETER Edition
29+
Specifies a free custom edition to use for the installation. This parameter
30+
is mutually exclusive with the parameter ProductKey.
31+
32+
.PARAMETER LogPath
33+
Specifies the file path where to write the log files, e.g. 'C:\Logs\Install.log'.
34+
By default log files are created under %TEMP%.
35+
36+
.PARAMETER InstallFolder
37+
Specifies the folder where to install the product, e.g. 'C:\Program Files\SSRS'.
38+
By default the product is installed under the default installation folder.
39+
40+
Reporting Services: %ProgramFiles%\Microsoft SQL Server Reporting Services
41+
PI Report Server: %ProgramFiles%\Microsoft Power BI Report Server
42+
43+
.PARAMETER SuppressRestart
44+
Suppresses the restart of the computer after the installation is finished.
45+
By default the computer is restarted after the installation is finished.
46+
47+
.PARAMETER Timeout
48+
Specifies how long to wait for the setup process to finish. Default value
49+
is `7200` seconds (2 hours). If the setup process does not finish before
50+
this time, an exception will be thrown.
51+
52+
.PARAMETER Force
53+
If specified the command will not ask for confirmation. Same as if Confirm:$false
54+
is used.
55+
56+
.EXAMPLE
57+
Install-SqlDscReportingServices -AcceptLicensingTerms -MediaPath 'E:\SQLServerReportingServices.exe'
58+
59+
Installs SQL Server Reporting Services with default settings.
60+
61+
.EXAMPLE
62+
Install-SqlDscReportingServices -AcceptLicensingTerms -MediaPath 'E:\SQLServerReportingServices.exe' -ProductKey '12345-12345-12345-12345-12345'
63+
64+
Installs SQL Server Reporting Services using a product key.
65+
66+
.EXAMPLE
67+
Install-SqlDscReportingServices -AcceptLicensingTerms -MediaPath 'E:\PowerBIReportServer.exe' -Edition 'Evaluation' -InstallFolder 'C:\Program Files\Power BI Report Server'
68+
69+
Installs Power BI Report Server in evaluation edition to a custom folder.
70+
71+
.EXAMPLE
72+
Install-SqlDscReportingServices -AcceptLicensingTerms -MediaPath 'E:\SQLServerReportingServices.exe' -ProductKey '12345-12345-12345-12345-12345' -EditionUpgrade -LogPath 'C:\Logs\SSRS_Install.log'
73+
74+
Installs SQL Server Reporting Services and upgrades the edition using a
75+
product key. Also specifies a custom log path.
76+
#>
77+
function Install-SqlDscReportingServices
78+
{
79+
[System.Diagnostics.CodeAnalysis.SuppressMessageAttribute('PSShouldProcess', '', Justification = 'Because ShouldProcess is used in Invoke-SetupAction')]
80+
[CmdletBinding(SupportsShouldProcess = $true, ConfirmImpact = 'High')]
81+
[OutputType()]
82+
param
83+
(
84+
[Parameter(Mandatory = $true)]
85+
[System.Management.Automation.SwitchParameter]
86+
$AcceptLicensingTerms,
87+
88+
[Parameter(Mandatory = $true)]
89+
[System.String]
90+
$MediaPath,
91+
92+
[Parameter()]
93+
[System.String]
94+
$ProductKey,
95+
96+
[Parameter()]
97+
[System.Management.Automation.SwitchParameter]
98+
$EditionUpgrade,
99+
100+
[Parameter()]
101+
[ValidateSet('Development', 'Evaluation', 'ExpressAdvanced')]
102+
[System.String]
103+
$Edition,
104+
105+
[Parameter()]
106+
[System.String]
107+
$LogPath,
108+
109+
[Parameter()]
110+
[System.String]
111+
$InstallFolder,
112+
113+
[Parameter()]
114+
[System.Management.Automation.SwitchParameter]
115+
$SuppressRestart,
116+
117+
[Parameter()]
118+
[System.UInt32]
119+
$Timeout = 7200,
120+
121+
[Parameter()]
122+
[System.Management.Automation.SwitchParameter]
123+
$Force
124+
)
125+
126+
Invoke-ReportServerSetupAction -Install @PSBoundParameters
127+
}
Lines changed: 123 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,123 @@
1+
<#
2+
.SYNOPSIS
3+
Repairs an existing SQL Server Reporting Services or Power BI Report Server
4+
installation.
5+
6+
.DESCRIPTION
7+
Repairs an existing SQL Server Reporting Services or Power BI Report Server
8+
installation using the provided setup executable.
9+
10+
.PARAMETER AcceptLicensingTerms
11+
Required parameter to be able to run unattended repair. By specifying this
12+
parameter you acknowledge the acceptance of all license terms and notices for
13+
the specified features, the terms and notices that the setup executable
14+
normally asks for.
15+
16+
.PARAMETER MediaPath
17+
Specifies the path where to find the SQL Server installation media. On this
18+
path the SQL Server setup executable must be found.
19+
20+
.PARAMETER ProductKey
21+
Specifies the product key to use for the repair, e.g. '12345-12345-12345-12345-12345'.
22+
This parameter is mutually exclusive with the parameter Edition.
23+
24+
.PARAMETER EditionUpgrade
25+
Upgrades the edition of the installed product. Requires that either the
26+
ProductKey or the Edition parameter is also assigned. By default no edition
27+
upgrade is performed.
28+
29+
.PARAMETER Edition
30+
Specifies a free custom edition to use for the repair. This parameter
31+
is mutually exclusive with the parameter ProductKey.
32+
33+
.PARAMETER LogPath
34+
Specifies the file path where to write the log files, e.g. 'C:\Logs\Repair.log'.
35+
By default log files are created under %TEMP%.
36+
37+
.PARAMETER InstallFolder
38+
Specifies the folder where to install the product, e.g. 'C:\Program Files\SSRS'.
39+
By default the product is installed under the default installation folder.
40+
41+
Reporting Services: %ProgramFiles%\Microsoft SQL Server Reporting Services
42+
PI Report Server: %ProgramFiles%\Microsoft Power BI Report Server
43+
44+
.PARAMETER SuppressRestart
45+
Suppresses the restart of the computer after the repair is finished.
46+
By default the computer is restarted after the repair is finished.
47+
48+
.PARAMETER Timeout
49+
Specifies how long to wait for the setup process to finish. Default value
50+
is `7200` seconds (2 hours). If the setup process does not finish before
51+
this time, an exception will be thrown.
52+
53+
.PARAMETER Force
54+
If specified the command will not ask for confirmation. Same as if Confirm:$false
55+
is used.
56+
57+
.EXAMPLE
58+
Repair-SqlDscReportingServices -AcceptLicensingTerms -MediaPath 'E:\SQLServerReportingServices.exe'
59+
60+
Repairs SQL Server Reporting Services with default settings.
61+
62+
.EXAMPLE
63+
Repair-SqlDscReportingServices -AcceptLicensingTerms -MediaPath 'E:\SQLServerReportingServices.exe' -ProductKey '12345-12345-12345-12345-12345' -EditionUpgrade
64+
65+
Repairs SQL Server Reporting Services and upgrades the edition using a
66+
product key.
67+
68+
.EXAMPLE
69+
Repair-SqlDscReportingServices -AcceptLicensingTerms -MediaPath 'E:\PowerBIReportServer.exe' -LogPath 'C:\Logs\PowerBIReportServer_Repair.log'
70+
71+
Repairs Power BI Report Server and specifies a custom log path.
72+
#>
73+
function Repair-SqlDscReportingServices
74+
{
75+
[System.Diagnostics.CodeAnalysis.SuppressMessageAttribute('PSShouldProcess', '', Justification = 'Because ShouldProcess is used in Invoke-SetupAction')]
76+
[CmdletBinding(SupportsShouldProcess = $true, ConfirmImpact = 'High')]
77+
[OutputType()]
78+
param
79+
(
80+
[Parameter(Mandatory = $true)]
81+
[System.Management.Automation.SwitchParameter]
82+
$AcceptLicensingTerms,
83+
84+
[Parameter(Mandatory = $true)]
85+
[System.String]
86+
$MediaPath,
87+
88+
[Parameter()]
89+
[System.String]
90+
$ProductKey,
91+
92+
[Parameter()]
93+
[System.Management.Automation.SwitchParameter]
94+
$EditionUpgrade,
95+
96+
[Parameter()]
97+
[ValidateSet('Development', 'Evaluation', 'ExpressAdvanced')]
98+
[System.String]
99+
$Edition,
100+
101+
[Parameter()]
102+
[System.String]
103+
$LogPath,
104+
105+
[Parameter()]
106+
[System.String]
107+
$InstallFolder,
108+
109+
[Parameter()]
110+
[System.Management.Automation.SwitchParameter]
111+
$SuppressRestart,
112+
113+
[Parameter()]
114+
[System.UInt32]
115+
$Timeout = 7200,
116+
117+
[Parameter()]
118+
[System.Management.Automation.SwitchParameter]
119+
$Force
120+
)
121+
122+
Invoke-ReportServerSetupAction -Repair @PSBoundParameters
123+
}
Lines changed: 74 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,74 @@
1+
<#
2+
.SYNOPSIS
3+
Uninstalls SQL Server Reporting Services or Power BI Report Server.
4+
5+
.DESCRIPTION
6+
Uninstalls SQL Server Reporting Services or Power BI Report Server using
7+
the provided setup executable.
8+
9+
.PARAMETER MediaPath
10+
Specifies the path where to find the SQL Server installation media. On this
11+
path the SQL Server setup executable must be found.
12+
13+
.PARAMETER LogPath
14+
Specifies the file path where to write the log files, e.g. 'C:\Logs\Uninstall.log'.
15+
By default log files are created under %TEMP%.
16+
17+
.PARAMETER SuppressRestart
18+
Suppresses the restart of the computer after the uninstallation is finished.
19+
By default the computer is restarted after the uninstallation is finished.
20+
21+
.PARAMETER Timeout
22+
Specifies how long to wait for the setup process to finish. Default value
23+
is `7200` seconds (2 hours). If the setup process does not finish before
24+
this time, an exception will be thrown.
25+
26+
.PARAMETER Force
27+
If specified the command will not ask for confirmation. Same as if Confirm:$false
28+
is used.
29+
30+
.EXAMPLE
31+
Uninstall-SqlDscReportingServices -MediaPath 'E:\SQLServerReportingServices.exe'
32+
33+
Uninstalls SQL Server Reporting Services.
34+
35+
.EXAMPLE
36+
Uninstall-SqlDscReportingServices -MediaPath 'E:\PowerBIReportServer.exe' -LogPath 'C:\Logs\PowerBIReportServer_Uninstall.log'
37+
38+
Uninstalls Power BI Report Server and specifies a custom log path.
39+
40+
.EXAMPLE
41+
Uninstall-SqlDscReportingServices -MediaPath 'E:\SQLServerReportingServices.exe' -Force
42+
43+
Uninstalls SQL Server Reporting Services without prompting for confirmation.
44+
#>
45+
function Uninstall-SqlDscReportingServices
46+
{
47+
[System.Diagnostics.CodeAnalysis.SuppressMessageAttribute('PSShouldProcess', '', Justification = 'Because ShouldProcess is used in Invoke-SetupAction')]
48+
[CmdletBinding(SupportsShouldProcess = $true, ConfirmImpact = 'High')]
49+
[OutputType()]
50+
param
51+
(
52+
[Parameter(Mandatory = $true)]
53+
[System.String]
54+
$MediaPath,
55+
56+
[Parameter()]
57+
[System.String]
58+
$LogPath,
59+
60+
[Parameter()]
61+
[System.Management.Automation.SwitchParameter]
62+
$SuppressRestart,
63+
64+
[Parameter()]
65+
[System.UInt32]
66+
$Timeout = 7200,
67+
68+
[Parameter()]
69+
[System.Management.Automation.SwitchParameter]
70+
$Force
71+
)
72+
73+
Invoke-ReportServerSetupAction -Uninstall @PSBoundParameters
74+
}

0 commit comments

Comments
 (0)