JamesDBartlett3 / PowerBits

A collection of useful, time-saving tools for working with Microsoft Power BI
Open Software License 3.0
49 stars 13 forks source link

Copy-PowerBIReportContentToBlankPBIXFile doesn't work for reports in My Workspace #1

Closed rudzimj closed 2 years ago

rudzimj commented 2 years ago

There is no ID for My Workspace. To make it work, I changed $true to $false here:

    [parameter(Mandatory = $false)][string]$sourceWorkspaceId,

And added this logic:

    if ($targetWorkspaceId -eq "") {
      $endpointUri = "$pbiApiBaseUri/reports/$targetReportId/UpdateReportContent"
    } else {
      $endpointUri = "$pbiApiBaseUri/groups/$targetWorkspaceId/reports/$targetReportId/UpdateReportContent"
    }

It would also be nice to add a sample to invoke the function:

#For My Workspace, no need to provide WorkspaceID
Copy-PowerBIReportContentToBlankPBIXFile -sourceReportId 6a9ffeff-5d4f-4526-bfc9-2b77fc756f71 -targetReportId 32b273ff-b40f-48ff-86ea-20c0e2c55cc1
JamesDBartlett3 commented 2 years ago

Cool idea. Feel free to submit a PR, and I'll merge it.

Update: See comment below.

JamesDBartlett3 commented 2 years ago

@rudzimj, I just discovered that Microsoft has finally rolled out native support for downloading reports originally authored in the Power BI service.

image

Therefore, this function is no longer strictly necessary, and as such, I won't be making any future modifications to it. For now, I've decided to keep it here, so it can serve as a teaching aid, to refresh my own memory, and of course, as training data for GitHub Copilot! 😉

Thank you for bringing my attention to this issue, and I hope you'll continue contributing to this repository going forward.

~ James