Over a million developers have joined DZone.

Working With SQL Server Reporting Server PowerShell

DZone's Guide to

Working With SQL Server Reporting Server PowerShell

Learn how to remap SSRS or SQL Server Reporting Server Database to an existing database by working with SSRS PowerShell.

· Database Zone ·
Free Resource

Slow SQL Server? These SentryOne resources share tips and tricks for not only troubleshooting SQL Server performance issues, but also preventing them before they hit your production environment.

In this post, we will see how to work with SSRS PowerShell so we can remap SSRS or SQL Server Reporting Server Database to an existing DB. We will see also how to restore SSRS encryption keys.

First, download the PowerShell SSRS Modules using NuGet for PowerShell (NuGet Provider), run PowerShell as admin, and type the following:

Install-Module -Name ReportingServicesTools

Because I didn’t have NuGet for PowerShell, I got the following message:

NuGet provider is required to continue
PowerShellGet requires NuGet provider version '' or newer to interact with NuGet-based repositories. The NuGet provider must be available in 'C:\Program
Files\PackageManagement\ProviderAssemblies' or 'C:\Users\mradwan\AppData\Local\PackageManagement\ProviderAssemblies'. You can also install the NuGet provider by running
'Install-PackageProvider -Name NuGet -MinimumVersion -Force'. Do you want PowerShellGet to install and import the NuGet provider now?
[Y] Yes [N] No [S] Suspend [?] Help (default is "Y"):

By agreeing, it will install both NuGet and SSRS PowerShell Modules. To display all the commands in that module, type:

Get-Command -Module ReportingServicesTools

This will display all the commands:

Image title

To know how to use the needed command, type:

get-help set-rsdatabase

This will download the latest solution and display the solution. To see some examples of how to use that command, type:

get-help set-rsdatabase -examples

Image title


Change the SSRS database to map to the old DB (I used the new name of the machine):

Set-RsDatabase -DatabaseServerName MyServer_Name -Name MyReportServerDB_Name -IsExistingDatabase -DatabaseCredentialType ServiceAccount -Confirm:$false

Restore the SSRS encryption key:

Restore-RSEncryptionKey -Password 'MyPassword' -KeyPath 'C:\Partial Autoamtion\CRMSRSReportKey.snk'

And that's it!

Database monitoring tools letting you down? See how SentryOne empowers Enterprises to go faster.

database ,sql ,ssrs ,powershell ,tutorial ,encryption

Published at DZone with permission of

Opinions expressed by DZone contributors are their own.

{{ parent.title || parent.header.title}}

{{ parent.tldr }}

{{ parent.urlSource.name }}