DEV Community

Kenichiro Nakamura
Kenichiro Nakamura

Posted on

4 2

Export pbix file from Power BI service via PowerShell

Power BI let's you download pbix from UI but you can also export it via API.

Download a report from the Power BI service to Power BI Desktop

Power BI Rest API: Reports - Export Report

Power BI team also released PowerShell module for PowerBI. So I explain how you can download pbix file via PowerShell.

Check the Report Id

Open a report on Power BI service and confirm the report id.
Alt Text

PowerShell

Open PowerShell as Administrator and install PowerBI module.

Install-Module -Name MicrosoftPowerBIMgmt

Then login to Power BI service.

Login-PowerBI

Finally download pbix file.

  • Replace ReportId
  • Replace OutFile
$date = (Get-Date).ToString("yyyyMMdd")
$ReportId = "960e6b3d-b1ce-49fb-8e87-201d6e02f1e0"
$OutFile = "C:\Users\kenakamu\Desktop\test$date.pbix"

Invoke-PowerBIRestMethod -Method GET `
-Url https://api.powerbi.com/v1.0/myorg/reports/${ReportId}/Export `
-ContentType "application/zip" -OutFile $OutFile

It fails if the file already exists, so I use date to make unique name.

Image of Stellar post

🚀 Stellar Dev Diaries Series: Episode 1 is LIVE!

Ever wondered what it takes to build a web3 startup from scratch? In the Stellar Dev Diaries series, we follow the journey of a team of developers building on the Stellar Network as they go from hackathon win to getting funded and launching on mainnet.

Read more

Top comments (1)

Collapse
 
cloudstakes profile image
CloudStakes Technology

Thank you for sharing this insightful article on the Power BI service via PowerShell.

Sentry image

See why 4M developers consider Sentry, “not bad.”

Fixing code doesn’t have to be the worst part of your day. Learn how Sentry can help.

Learn more

👋 Kindness is contagious

Engage with a wealth of insights in this thoughtful article, cherished by the supportive DEV Community. Coders of every background are encouraged to bring their perspectives and bolster our collective wisdom.

A sincere “thank you” often brightens someone’s day—share yours in the comments below!

On DEV, the act of sharing knowledge eases our journey and forges stronger community ties. Found value in this? A quick thank-you to the author can make a world of difference.

Okay