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 Timescale

Timescale – the developer's data platform for modern apps, built on PostgreSQL

Timescale Cloud is PostgreSQL optimized for speed, scale, and performance. Over 3 million IoT, AI, crypto, and dev tool apps are powered by Timescale. Try it free today! No credit card required.

Try free

Top comments (1)

Collapse
 
cloudstakes profile image
CloudStakes Technology

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

Billboard image

The Next Generation Developer Platform

Coherence is the first Platform-as-a-Service you can control. Unlike "black-box" platforms that are opinionated about the infra you can deploy, Coherence is powered by CNC, the open-source IaC framework, which offers limitless customization.

Learn more

👋 Kindness is contagious

Dive into an ocean of knowledge with this thought-provoking post, revered deeply within the supportive DEV Community. Developers of all levels are welcome to join and enhance our collective intelligence.

Saying a simple "thank you" can brighten someone's day. Share your gratitude in the comments below!

On DEV, sharing ideas eases our path and fortifies our community connections. Found this helpful? Sending a quick thanks to the author can be profoundly valued.

Okay