Powershell Script to export SSRS subscriptions from One SSRS to Another

Here is a PowerShell script that can be used to export subscriptions from one Microsoft SQL Server Reporting Services (SSRS) server and import them to another SSRS server:

# Load the ReportingServices libraries [void][System.Reflection.Assembly]::LoadWithPartialName("Microsoft.SqlServer.Management.ReportingServices") # Connect to the source SSRS server $sourceServer = "SourceServerName" $sourceSsrs = New-WebServiceProxy -Uri "http://$sourceServer/ReportServer/ReportService2010.asmx?WSDL" -Namespace SSRS.ReportingService2010 -UseDefaultCredential # Get a list of all subscriptions on the source SSRS server $subscriptions = $sourceSsrs.ListSubscriptions("/") # Export the subscriptions to a CSV file $subscriptions | Select-Object Path, Report, EventType, @{Name="DeliveryExtension";Expression={$_.Extension}}, @{Name="Description";Expression={$_.Description}} | Export-Csv "Subscriptions.csv" -NoTypeInformation # Disconnect from the source SSRS server $sourceSsrs = $null # Connect to the destination SSRS server $destinationServer = "DestinationServerName" $destinationSsrs = New-WebServiceProxy -Uri "http://$destinationServer/ReportServer/ReportService2010.asmx?WSDL" -Namespace SSRS.ReportingService2010 -UseDefaultCredential # Load the subscriptions from the CSV file $subscriptions = Import-Csv "Subscriptions.csv" # Loop through each subscription in the CSV file foreach ($subscription in $subscriptions) { # Create a new subscription for each entry in the CSV file $newSubscription = New-Object Microsoft.SqlServer.Management.ReportingServices.Execution.ReportExecutionService.Subscription $newSubscription.Path = $subscription.Path $newSubscription.Extension = $subscription.DeliveryExtension $newSubscription.EventType = [Microsoft.SqlServer.Management.ReportingServices.Execution.ReportExecutionService.EventType]::$($subscription.EventType) $newSubscription.Description = $subscription.Description # Create the new subscription $destinationSsrs.CreateSubscription($newSubscription) } # Disconnect from the destination SSRS server $destinationSsrs = $null


This script starts by loading the ReportingServices libraries and connecting to the source SSRS server using the New-WebServiceProxy cmdlet. It then retrieves a list of all subscriptions on the source SSRS server using the ListSubscriptions method of the $sourceSsrs object.

The list of subscriptions is then exported to a CSV file using the Export-Csv cmdlet. The properties that are exported include the path of the report, the name of the report, the type of event that triggers the subscription, the delivery extension used to send the report, and the description of the subscription.

The script then disconnects from the source SSRS server and connects to the destination SSRS server using the New-WebServiceProxy cmdlet. The subscriptions from the CSV file are then imported and used to create new subscriptions on the destination SSRS server using

No comments:

Post a Comment