Automating GitHub RDLs to Bold Reports Migration Using PowerShell Script
Overview
This article explains how to automate the migration of .rdl report files from a GitHub repository to Bold Reports Server using a PowerShell script. The script performs a bulk upload in a single execution, reducing manual effort and ensuring consistent deployment.
In many reporting workflows, report definitions are stored in source control systems such as GitHub. Migrating these reports manually into Bold Reports Server is repetitive and time-consuming. The PowerShell script provided in this article automates the following tasks:
- Retrieves
.rdlfiles from a GitHub repository folder - Downloads each report file to a temporary local directory
- Converts file content to Base64 format
- Uploads each report to Bold Reports Server via REST API
Prerequisites
Before running the script, ensure the following requirements are met:
- A GitHub repository that contains
.rdlreport files - The GitHub API URL for the repository folder (contents endpoint)
- A running Bold Reports Server instance
- A valid Bearer Token for Bold Reports Server authentication
- PowerShell 5.1 or later
How It Works
The script performs the following steps:
- Connects to GitHub using the provided API URL
- Filters and retrieves all
.rdlfiles from the specified folder - Downloads each file to a temporary local directory
- Converts each file to Base64 format
- Uploads each report to Bold Reports Server using the REST API
- Displays a success or error message for each report processed
Script Parameters
| Parameter | Description |
|---|---|
GitHubApiUrl |
GitHub contents API URL of the repository folder |
ReportServerApiUrl |
Bold Reports Server API base URL |
Token |
Bearer token for Bold Reports Server authentication |
ServerPath |
Destination folder path in Bold Reports Server |
TempDir |
Temporary local folder for downloaded report files |
Important: Update all parameter values in the script before running it.
Script Usage
Run the Script
Follow the steps below to execute the PowerShell script:
- Save the script file as
MigrateReports.ps1 - Open PowerShell with the necessary permissions
- Navigate to the folder where the script is saved
- Run the saved script file
PowerShell Script
<#
.SYNOPSIS
Downloads .rdl files from a GitHub folder and uploads them to Bold Reports Server.
.DESCRIPTION
- Downloads all .rdl files from the specified GitHub repository folder
- Uploads each report into the configured folder on Bold Reports Server
- Authorization token must already exist (script does not generate tokens)
.USAGE
Example command:
./MigrateReports.ps1 `
-GitHubApiUrl "https://api.github.com/repos/<USERNAME>/<REPO>/contents/<FOLDER>" `
-ReportServerApiUrl "http://<SERVER>:<PORT>/reporting/api/site/<SITE_NAME>" `
-Token "bearer <YOUR_AUTH_TOKEN>" `
-ServerPath "/MyReports/"
#>
param(
# GitHub folder API URL (contents endpoint)
[string]$GitHubApiUrl = "<ENTER_GITHUB_CONTENTS_API_URL>",
# Bold Reports API base URL
[string]$ReportServerApiUrl = "<ENTER_BOLD_REPORTS_API_URL>",
# Bearer token for authorization
[string]$Token = "bearer <ENTER_YOUR_TOKEN>",
# Folder inside Bold Reports Server where reports will be uploaded
[string]$ServerPath = "/GitReports/",
# Local temp folder to hold downloaded files
[string]$TempDir = "$env:TEMP\GitReports"
)
# Ensure temp directory exists
if (-not (Test-Path -Path $TempDir)) {
New-Item -Path $TempDir -ItemType Directory | Out-Null
}
# ---------------------------- FUNCTIONS ---------------------------- #
function Get-ReportFilesFromGitHub {
param([string]$ApiUrl)
try {
$headers = @{ 'User-Agent' = 'PowerShell' }
$response = Invoke-RestMethod -Uri $ApiUrl -Headers $headers -ErrorAction Stop
return $response | Where-Object { $_.name -like "*.rdl" } | ForEach-Object {
[PSCustomObject]@{
Name = $_.name
DownloadUrl = $_.download_url
}
}
}
catch {
Write-Warning "Error fetching GitHub list: $($_.Exception.Message)"
return @()
}
}
function Get-FileBytes {
param(
[string]$Url,
[string]$OutDir
)
$tmpFile = Join-Path $OutDir ([System.IO.Path]::GetRandomFileName())
try {
Invoke-WebRequest -Uri $Url -OutFile $tmpFile -ErrorAction Stop
return [System.IO.File]::ReadAllBytes($tmpFile)
}
catch {
Write-Warning "Download failed: $Url - $($_.Exception.Message)"
return $null
}
finally {
if (Test-Path $tmpFile) { Remove-Item $tmpFile -Force }
}
}
function Add-Report {
param(
[string]$ReportName,
[byte[]]$ReportBytes,
[string]$ApiBaseUrl,
[string]$AuthToken,
[string]$UploadServerPath
)
if (-not $ReportBytes) {
Write-Warning "Skipping $ReportName — no file bytes found."
return
}
$base64 = [System.Convert]::ToBase64String($ReportBytes)
$payload = @{
Name = $ReportName
ItemContent = $base64
IsPublic = $false
ServerPath = $UploadServerPath
}
$json = $payload | ConvertTo-Json -Depth 10
$headers = @{
Authorization = $AuthToken
"Content-Type" = "application/json"
}
$uri = $ApiBaseUrl.TrimEnd('/') + "/v1.0/reports"
try {
return Invoke-RestMethod -Method Post -Uri $uri -Headers $headers -Body $json -ErrorAction Stop
}
catch {
if ($_.Exception.Response) {
$reader = New-Object System.IO.StreamReader($_.Exception.Response.GetResponseStream())
$body = $reader.ReadToEnd()
Write-Warning "Upload failed for $ReportName: $body"
}
else {
Write-Warning "Upload failed for $ReportName: $($_.Exception.Message)"
}
}
}
# ---------------------------- MAIN PROCESS ---------------------------- #
try {
Write-Host "Fetching .rdl files from GitHub..."
$files = Get-ReportFilesFromGitHub -ApiUrl $GitHubApiUrl
if ($files.Count -eq 0) {
Write-Host "No .rdl files found at: $GitHubApiUrl"
}
else {
Write-Host "Found $($files.Count) report(s). Uploading..."
foreach ($f in $files) {
Write-Host "`nProcessing: $($f.Name)"
$bytes = Get-FileBytes -Url $f.DownloadUrl -OutDir $TempDir
if ($bytes) {
$result = Add-Report `
-ReportName $f.Name `
-ReportBytes $bytes `
-ApiBaseUrl $ReportServerApiUrl `
-AuthToken $Token `
-UploadServerPath $ServerPath
if ($result) {
Write-Host "SUCCESS: $($f.Name)"
}
}
else {
Write-Warning "Skipping $($f.Name) — download failed."
}
}
}
Write-Host "`nMigration Completed!"
}
finally {
Read-Host -Prompt "Press Enter to exit"
}
Output Snapshots
Conclusion
This PowerShell script provides a reliable and efficient way to migrate .rdl reports from GitHub to Bold Reports Server. By automating both the download and upload processes, it minimizes manual effort and eliminates the risk of errors during migration.
Key benefits:
- Migrates all reports in a single execution
- Requires minimal manual effort
- Handles multiple reports efficiently
- Fully reusable and customizable for different repositories and server environments