Skip to content

Commit b98fb0f

Browse files
author
FriedrichWeinmann
committed
Compliance Update
Implemented all the reviewed / requested / required changes.
1 parent 0c459a8 commit b98fb0f

32 files changed

+637
-1089
lines changed

Functions/Admin/Backup-RsEncryptionKey.ps1

+3-39
Original file line numberDiff line numberDiff line change
@@ -50,23 +50,6 @@ function Backup-RsEncryptionKey
5050
-----------
5151
This command will back up the encryption key against named instance (SQL2012) from SQL Server 2012 Reporting Services.
5252
To do so, it will not use the default connection, but rather connect to the computer "sql2012a243", prompting the user for connection credentials.
53-
54-
.NOTES
55-
Author: ???
56-
Editors: Friedrich Weinmann
57-
Created on: ???
58-
Last Change: 31.01.2017
59-
Version: 1.1
60-
61-
Release 1.1 (26.01.2017, Friedrich Weinmann)
62-
- Fixed Parameter help (Don't poison the name with "(optional)", breaks Get-Help)
63-
- Implemented ShouldProcess (-WhatIf, -Confirm)
64-
- Replaced calling exit with throwing a terminating error (exit is a bit of an overkill when failing a simple execution)
65-
- Improved error message on failure.
66-
- Standardized the parameters governing the Report Server connection for consistent user experience.
67-
68-
Release 1.0 (???, ???)
69-
- Initial Release
7053
#>
7154

7255
[CmdletBinding(SupportsShouldProcess = $true, ConfirmImpact = 'Medium')]
@@ -85,7 +68,7 @@ function Backup-RsEncryptionKey
8568
$ReportServerInstance,
8669

8770
[Alias('SqlServerVersion')]
88-
[ReportingServicesTools.SqlServerVersion]
71+
[Microsoft.ReportingServicesTools.SqlServerVersion]
8972
$ReportServerVersion,
9073

9174
[string]
@@ -95,28 +78,9 @@ function Backup-RsEncryptionKey
9578
$Credential
9679
)
9780

98-
if ($ComputerName) { $tempComputerName = $ComputerName }
99-
else { $tempComputerName = ([ReportingServicesTools.ConnectionHost]::ComputerName) }
100-
if ($ReportServerInstance) { $tempInstanceName = $ReportServerInstance }
101-
else { $tempInstanceName = ([ReportingServicesTools.ConnectionHost]::Instance) }
102-
103-
if ($PSCmdlet.ShouldProcess("$tempComputerName \ $tempInstanceName", "Retrieve encryption key and create backup in $KeyPath"))
81+
if ($PSCmdlet.ShouldProcess((Get-ShouldProcessTargetWmi -BoundParameters $PSBoundParameters), "Retrieve encryption key and create backup in $KeyPath"))
10482
{
105-
#region Connect to Report Server using WMI
106-
try
107-
{
108-
$splat = @{ }
109-
if ($PSBoundParameters.ContainsKey('ReportServerInstance')) { $splat['ReportServerInstance'] = $ReportServerInstance }
110-
if ($PSBoundParameters.ContainsKey('ReportServerVersion')) { $splat['ReportServerVersion'] = $ReportServerVersion }
111-
if ($PSBoundParameters.ContainsKey('ComputerName')) { $splat['ComputerName'] = $ComputerName }
112-
if ($PSBoundParameters.ContainsKey('Credential')) { $splat['Credential'] = $Credential }
113-
$rsWmiObject = New-RsConfigurationSettingObject @splat
114-
}
115-
catch
116-
{
117-
throw
118-
}
119-
#endregion Connect to Report Server using WMI
83+
$rsWmiObject = New-RsConfigurationSettingObjectHelper -BoundParameters $PSBoundParameters
12084

12185
Write-Verbose "Retrieving encryption key..."
12286
$encryptionKeyResult = $rsWmiObject.BackupEncryptionKey($Password)

Functions/Admin/Register-RsPowerBI.ps1

+5-43
Original file line numberDiff line numberDiff line change
@@ -58,28 +58,9 @@ function Register-RsPowerBI
5858
Use the "Connect-RsReportServer" function to set/update a default value.
5959
6060
.EXAMPLE
61-
Register-RsPowerBI -ClientId 'value1' -ClientSecret 'value2' -AppObjectId 'value3' -TenantName 'value4' -TenantId 'value5' -RedirectUrls 'value6'
61+
Register-PowerBI -ClientId "UpdateWithClientID" -ClientSecret "UpdateWithClientSecret" -AppObjectId "UpdateWithObjectId" -TenantName "UpdateWithTenantName" -TenantId "UpdateWithTenantId" -RedirectUrls "UpdateWithRedirectUrls" -ReportServerInstance "UpdateWithSqlServerInstance"
6262
63-
<Insert description here>
64-
65-
.NOTES
66-
Author: ???
67-
Editors: Friedrich Weinmann
68-
Created on: ???
69-
Last Change: 26.01.2017
70-
Version: 1.1
71-
72-
Release 1.1 (26.01.2017, Friedrich Weinmann)
73-
- Fixed Parameter help (Don't poison the name with "(optional)", breaks Get-Help)
74-
- Implemented ShouldProcess (-WhatIf, -Confirm)
75-
- Replaced calling exit with throwing a terminating error (exit is a bit of an overkill when failing a simple execution)
76-
- Improved error message on failure.
77-
- Standardized the parameters governing the Report Server connection for consistent user experience.
78-
- Added input validation, to ensure no out-of-date servers are specified.
79-
- Renamed function from "Register-PowerBI" to "Register-RsPowerBI", in order to conform to naming standards and include the module prefix. Introduced an alias with the old name for backwards compatibility.
80-
81-
Release 1.0 (???, ???)
82-
- Initial Release
63+
Connects the Report Server to the previously configured Azure Active Directory Web App for direct integration into PowerBI.
8364
8465
.LINK
8566
https://blogs.msdn.microsoft.com/sqlrsteamblog/2016/07/22/manually-configuring-power-bi-integration-in-reporting-services/
@@ -126,7 +107,7 @@ function Register-RsPowerBI
126107
$ReportServerInstance,
127108

128109
[Alias('SqlServerVersion')]
129-
[ReportingServicesTools.SqlServerVersion]
110+
[Microsoft.ReportingServicesTools.SqlServerVersion]
130111
$ReportServerVersion,
131112

132113
[string]
@@ -136,28 +117,9 @@ function Register-RsPowerBI
136117
$Credential
137118
)
138119

139-
if ($ComputerName) { $tempComputerName = $ComputerName }
140-
else { $tempComputerName = ([ReportingServicesTools.ConnectionHost]::ComputerName) }
141-
if ($ReportServerInstance) { $tempInstanceName = $ReportServerInstance }
142-
else { $tempInstanceName = ([ReportingServicesTools.ConnectionHost]::Instance) }
143-
144-
if ($PSCmdlet.ShouldProcess("$tempComputerName \ $tempInstanceName", "Registering PowerBI for SQL Server Instance"))
120+
if ($PSCmdlet.ShouldProcess((Get-ShouldProcessTargetWmi -BoundParameters $PSBoundParameters), "Registering PowerBI for SQL Server Instance"))
145121
{
146-
#region Connect to Report Server using WMI
147-
try
148-
{
149-
$splat = @{ }
150-
if ($PSBoundParameters.ContainsKey('ReportServerInstance')) { $splat['ReportServerInstance'] = $ReportServerInstance }
151-
if ($PSBoundParameters.ContainsKey('ReportServerVersion')) { $splat['ReportServerVersion'] = $ReportServerVersion }
152-
if ($PSBoundParameters.ContainsKey('ComputerName')) { $splat['ComputerName'] = $ComputerName }
153-
if ($PSBoundParameters.ContainsKey('Credential')) { $splat['Credential'] = $Credential }
154-
$rsWmiObject = New-RsConfigurationSettingObject @splat -MinimumSqlServerVersion "SQLServer2016"
155-
}
156-
catch
157-
{
158-
throw
159-
}
160-
#endregion Connect to Report Server using WMI
122+
$rsWmiObject = New-RsConfigurationSettingObjectHelper -BoundParameters $PSBoundParameters
161123

162124
Write-Verbose "Configuring Power BI ..."
163125
$configureResult = $rsWmiObject.SavePowerBIInformation($ClientId,

Functions/Admin/Restore-RsEncryptionKey.ps1

+33-62
Original file line numberDiff line numberDiff line change
@@ -6,10 +6,16 @@ function Restore-RSEncryptionKey
66
<#
77
.SYNOPSIS
88
This script restores the SQL Server Reporting Services encryption key.
9-
9+
1010
.DESCRIPTION
1111
This script restores encryption key for SQL Server Reporting Services. This key is needed in order to read all the encrypted content stored in the Reporting Services Catalog database.
12-
12+
13+
.PARAMETER Password
14+
Specify the password that was used when the encryption key was backed up.
15+
16+
.PARAMETER KeyPath
17+
Specify the path to where the encryption key is stored.
18+
1319
.PARAMETER ReportServerInstance
1420
Specify the name of the SQL Server Reporting Services Instance.
1521
Use the "Connect-RsReportServer" function to set/update a default value.
@@ -25,13 +31,7 @@ function Restore-RSEncryptionKey
2531
.PARAMETER Credential
2632
The credentials with which to connect to the Report Server.
2733
Use the "Connect-RsReportServer" function to set/update a default value.
28-
29-
.PARAMETER Password
30-
Specify the password that was used when the encryption key was backed up.
31-
32-
.PARAMETER KeyPath
33-
Specify the path to where the encryption key is stored.
34-
34+
3535
.EXAMPLE
3636
Restore-RSEncryptionKey -Password 'Enter Your Password' -KeyPath 'C:\ReportingServices\Default.snk'
3737
Description
@@ -43,71 +43,42 @@ function Restore-RSEncryptionKey
4343
Description
4444
-----------
4545
This command will restore the encryption key to the named instance (SQL2012) from SQL Server 2012 Reporting Services
46-
47-
.NOTES
48-
Author: ???
49-
Editors: Friedrich Weinmann
50-
Created on: ???
51-
Last Change: 26.01.2017
52-
Version: 1.1
53-
54-
Release 1.1 (26.01.2017, Friedrich Weinmann)
55-
- Fixed Parameter help (Don't poison the name with "(optional)", breaks Get-Help)
56-
- Implemented ShouldProcess (-WhatIf, -Confirm)
57-
- Replaced calling exit with throwing a terminating error (exit is a bit of an overkill when failing a simple execution)
58-
- Improved error message on failure.
59-
- Standardized the parameters governing the Report Server connection for consistent user experience.
60-
- Try/Catch when reading from file. No special logic involved, but shows that the possibility of failure was considered
61-
62-
Release 1.0 (???, ???)
63-
- Initial Release
6446
#>
6547

6648
[CmdletBinding(SupportsShouldProcess = $true, ConfirmImpact = 'Medium')]
6749
param
6850
(
51+
[Parameter(Mandatory = $True)]
52+
[string]
53+
$Password,
54+
55+
[Parameter(Mandatory = $True)]
56+
[string]
57+
$KeyPath,
58+
6959
[Alias('SqlServerInstance')]
7060
[string]
7161
$ReportServerInstance,
7262

7363
[Alias('SqlServerVersion')]
74-
[ReportingServicesTools.SqlServerVersion]
64+
[Microsoft.ReportingServicesTools.SqlServerVersion]
7565
$ReportServerVersion,
7666

7767
[string]
7868
$ComputerName,
7969

8070
[System.Management.Automation.PSCredential]
81-
$Credential,
82-
83-
[Parameter(Mandatory = $True)]
84-
[string]
85-
$Password,
86-
87-
[Parameter(Mandatory = $True)]
88-
[string]
89-
$KeyPath
71+
$Credential
9072
)
9173

92-
if (-not $ReportServerInstance) { $ReportServerInstance = [ReportingServicesTools.ConnectionHost]::Instance }
74+
if (-not $ReportServerInstance)
75+
{
76+
$ReportServerInstance = [Microsoft.ReportingServicesTools.ConnectionHost]::Instance
77+
}
9378

94-
if ($PSCmdlet.ShouldProcess($ReportServerInstance, "Restore encryptionkey from file $KeyPath"))
79+
if ($PSCmdlet.ShouldProcess((Get-ShouldProcessTargetWmi -BoundParameters $PSBoundParameters), "Restore encryptionkey from file $KeyPath"))
9580
{
96-
#region Connect to Report Server using WMI
97-
try
98-
{
99-
$splat = @{ }
100-
if ($PSBoundParameters.ContainsKey('ReportServerInstance')) { $splat['ReportServerInstance'] = $ReportServerInstance }
101-
if ($PSBoundParameters.ContainsKey('ReportServerVersion')) { $splat['ReportServerVersion'] = $ReportServerVersion }
102-
if ($PSBoundParameters.ContainsKey('ComputerName')) { $splat['ComputerName'] = $ComputerName }
103-
if ($PSBoundParameters.ContainsKey('Credential')) { $splat['Credential'] = $Credential }
104-
$rsWmiObject = New-RsConfigurationSettingObject @splat
105-
}
106-
catch
107-
{
108-
throw
109-
}
110-
#endregion Connect to Report Server using WMI
81+
$rsWmiObject = New-RsConfigurationSettingObjectHelper -BoundParameters $PSBoundParameters
11182

11283
$reportServerService = 'ReportServer'
11384

@@ -122,8 +93,14 @@ function Restore-RSEncryptionKey
12293
throw "No key was found at the specified location: $path"
12394
}
12495

125-
try { $keyBytes = [System.IO.File]::ReadAllBytes($KeyPath) }
126-
catch { throw }
96+
try
97+
{
98+
$keyBytes = [System.IO.File]::ReadAllBytes($KeyPath)
99+
}
100+
catch
101+
{
102+
throw
103+
}
127104

128105
Write-Verbose "Restoring encryption key..."
129106
$restoreKeyResult = $rsWmiObject.RestoreEncryptionKey($keyBytes, $keyBytes.Length, $Password)
@@ -139,12 +116,6 @@ function Restore-RSEncryptionKey
139116

140117
try
141118
{
142-
$splat = @{
143-
Name = $reportServerService
144-
ComputerName = $rsWmiObject.PSComputerName
145-
ErrorAction = 'Stop'
146-
}
147-
148119
$service = Get-Service -Name $reportServerService -ComputerName $rsWmiObject.PSComputerName -ErrorAction Stop
149120
Write-Verbose "Stopping Reporting Services Service..."
150121
$service.Stop()

0 commit comments

Comments
 (0)