我们正在将SSRS报告从Reportings Services移动到SSDT 2017。有成千上万的文件夹。如何在不手动创建文件夹结构的情况下将这些文件夹和.rdl文件导入SSDT?
发布于 2018-12-05 04:31:58
使用powershell的黑客攻击,基于来自https://github.com/Microsoft/Reporting-Services/blob/master/APISamples/powershell/powershellSamples.ps1的示例
Import-Module SqlServer
$targetReportDirectory = "c:\temp\rs" #where to put the files
If (-Not (Test-Path $targetReportDirectory)) {new-Item -Path $targetReportDirectory -ItemType directory -Force}
#recreate directory structure on disk
Invoke-Sqlcmd -ServerInstance localhost -Database ReportServer -Query "Select Path from [Catalog] Where Type = 1 and Nullif(Path, '') is not null --Folders" | ForEach {
$localpath = Join-Path $targetReportDirectory $_.Path
If (-Not (Test-Path $localpath)) {$f = new-Item -Path $localpath -ItemType directory -Force}
}
#pull all reports down
$ReportPortalUri = "http://localhost/Reports"
Invoke-Sqlcmd -ServerInstance localhost -Database ReportServer -Query "Select ItemID, Path from [Catalog] Where Type = 2 and Nullif(Path, '') is not null --Reports" | ForEach {
$catalogItemsApi = $ReportPortalUri + "/api/v1.0/catalogitems($($_.ItemID))/Content/`$value"
$response = Invoke-WebRequest -Uri $catalogItemsApi -Method Get -UseDefaultCredentials
$downloadPath = Join-Path $targetReportDirectory $($_.Path + ".rdl")
[System.IO.File]::WriteAllBytes($downloadPath, $response.Content)
}
https://stackoverflow.com/questions/53616727
复制相似问题