Skip to content

Instantly share code, notes, and snippets.

@SQLvariant
Last active March 26, 2022 14:36
Show Gist options
  • Star 2 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save SQLvariant/6018cf21c9a82c5757d51bed0b498523 to your computer and use it in GitHub Desktop.
Save SQLvariant/6018cf21c9a82c5757d51bed0b498523 to your computer and use it in GitHub Desktop.
Promote a Power BI Report from a QA Workspace to a Prod Workspace, while preserving the connection to the Prod database when the updated report lands in the Prod Workspace.
$source_workspace_ID = (Get-PowerBIWorkspace -Name 'QA-Workspace').Id
$report = Get-PowerBIReport -Name 'Regional Sales' -WorkspaceId $source_workspace_ID
$target_workspace_ID = (Get-PowerBIWorkspace -Name 'Prod-Workspace').Id
$targetReport = Get-PowerBIReport -Name 'Regional Sales' -WorkspaceId $target_workspace_ID
Copy-PowerBIReport -Report $report -WorkspaceId $source_workspace_ID -TargetWorkspaceId $target_workspace_ID -TargetDatasetId ($targetReport).DatasetId -OutVariable NewReport
<# Now to remove the old version of the report in the Prod workspace #>
#$url = 'https://api.powerbi.com/v1.0/myorg/groups/' + $target_workspace_ID + '/reports/' + $targetReport.Id
#Invoke-PowerBIRestMethod -Method Delete -Url $url
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment