Skip to content

Instantly share code, notes, and snippets.

@lontivero
Last active March 12, 2019 14:18
Show Gist options
  • Save lontivero/01047cab3848d4b9b395da01c0a1bf30 to your computer and use it in GitHub Desktop.
Save lontivero/01047cab3848d4b9b395da01c0a1bf30 to your computer and use it in GitHub Desktop.
Bulk reports upload
# Use -server "localhost" -targetFolderPath "/" -sourceFolderPath "MCCReport_En"
[CmdletBinding()]
param (
[string] $sourceFolderPath,
[string] $targetFolderPath,
[string] $server = "localhost"
)
$reportServerUri = "http://$server/ReportServer/ReportService2010.asmx?wsdl"
$rs = New-WebServiceProxy -Uri $reportServerUri -UseDefaultCredential -Namespace "SSRS"
$warnings = $null
Get-ChildItem -Path $sourceFolderPath -Include *.rdl | Foreach-Object {
$reportName = [System.IO.Path]::GetFileNameWithoutExtension($_.Name)
$bytes = [System.IO.File]::ReadAllBytes($_.FullName)
Write-Output "Uploading report ""$reportName"" to ""$targetFolderPath""..."
$report = $rs.CreateCatalogItem(
"Report", # Catalog item type
$reportName, # Report name
$targetFolderPath,# Destination folder
$true, # Overwrite report if it exists?
$bytes, # .rdl file contents
$null, # Properties to set.
[ref]$warnings) # Warnings that occured while uploading.
$warnings | ForEach-Object {
Write-Output ("Warning: {0}" -f $_.Message)
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment