-
-
Save lontivero/01047cab3848d4b9b395da01c0a1bf30 to your computer and use it in GitHub Desktop.
Bulk reports upload
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 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