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 Datadog

The Essential Toolkit for Front-end Developers

Take a user-centric approach to front-end monitoring that evolves alongside increasingly complex frameworks and single-page applications.

Get The Kit

Top comments (1)

Collapse
 
cloudstakes profile image
CloudStakes Technology

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

A Workflow Copilot. Tailored to You.

Pieces.app image

Our desktop app, with its intelligent copilot, streamlines coding by generating snippets, extracting code from screenshots, and accelerating problem-solving.

Read the docs

AWS Security LIVE!

Hosted by security experts, AWS Security LIVE! showcases AWS Partners tackling real-world security challenges. Join live and get your security questions answered.

Tune in to the full event

DEV is partnering to bring live events to the community. Join us or dismiss this billboard if you're not interested. ❤️