Prerequisites

  1. MicrosoftPowerBIMgmt module already installed
  2. To download a report, you at least must be a Contributor to the worskpace
  3. CSV file with two columns report_id and file_name. Report ID is the ID of the report from Power BI service and file name is what you want the file to be saved as.
  4. This will only download the report along with the data; i.e. not as a thin report with live connection. This option hasn't been made available yet in PowerShell as of writing this blog (10/11/2022)
  5. Be aware of limitations of downloading a report

The CSV file should be in the following format:

Script

Import-Module MicrosoftPowerBIMgmt
Connect-PowerBIServiceAccount

#Specify location of the CSV file. The code expects two columns: 'report_id' and 'file_name'
#Report_id is the Report ID of the Power BI report you want to download
#File name is the name you want the report to be saved as
$Csv = Import-Csv -Path "C:\Users\User\Downloads\download reports.csv"

#Specify where to download the PBIX
$path = "C:\Users\User\Downloads\"


foreach ($Csv in $Csv)
{
$report= $Csv.report_id
$file_name = $Csv.file_name

if ([string]::IsNullOrEmpty($report) -or ([string]::IsNullOrEmpty($file_name)))
    {

     Write-Output "Report ID or File name missing"  

    }

else 
    {

     Write-Output "Downloading.... " $file_name  
     Export-PowerBIReport -Id $report -OutFile  $path$file_name

    }

}

I will update this script when it's possible to download the thin report using PowerShell. If you find any errors or have a better version, please let me know.