Automate Power BI XMLA Integration Tasks from PowerShell

Ready to get started?

Download for a free trial:

Download Now

Learn more:

Power BI XMLA ADO.NET Provider

Rapidly create and deploy powerful .NET applications that integrate with Power BI XMLA.

Are you looking for a quick and easy way to access Power BI XMLA data from PowerShell? We show how to use the Cmdlets for Power BI XMLA and the CData ADO.NET Provider for Power BI XMLA to connect to Power BI XMLA data and synchronize, automate, download, and more.

The CData Cmdlets for Power BI XMLA are standard PowerShell cmdlets that make it easy to accomplish data cleansing, normalization, backup, and other integration tasks by enabling real-time access to Power BI XMLA.

Cmdlets or ADO.NET?

The cmdlets are not only a PowerShell interface to the Power BI XMLA API, but also an SQL interface; this tutorial shows how to use both to retrieve Power BI XMLA data. We also show examples of the ADO.NET equivalent, which is possible with the CData ADO.NET Provider for Power BI XMLA. To access Power BI XMLA data from other .NET applications, like LINQPad, use the CData ADO.NET Provider for Power BI XMLA.

After obtaining the needed connection properties, accessing Power BI XMLA data in PowerShell consists of three basic steps.

To connect, set the Url property to a valid PowerBIXMLA workspace. For instance, powerbi://


  1. Install the module:

    Install-Module PowerBIXMLACmdlets
  2. Connect:

    $powerbixmla = Connect-PowerBIXMLA -URL "$URL"
  3. Search for and retrieve data:

    $country = "Australia" $customer = Select-PowerBIXMLA -Connection $powerbixmla -Table "Customer" -Where "Country = `'$Country`'" $customer

    You can also use the Invoke-PowerBIXMLA cmdlet to execute SQL commands:

    $customer = Invoke-PowerBIXMLA -Connection $powerbixmla -Query 'SELECT * FROM Customer WHERE Country = @Country' -Params @{'@Country'='Australia'}


  1. Load the provider's assembly:

    [Reflection.Assembly]::LoadFile("C:\Program Files\CData\CData ADO.NET Provider for Power BI XMLA\lib\System.Data.CData.PowerBIXMLA.dll")
  2. Connect to Power BI XMLA:

    $conn= New-Object System.Data.CData.PowerBIXMLA.PowerBIXMLAConnection("URL=powerbi://;InitiateOAuth=GETANDREFRESH") $conn.Open()
  3. Instantiate the PowerBIXMLADataAdapter, execute an SQL query, and output the results:

    $sql="SELECT Country, Education from Customer" $da= New-Object System.Data.CData.PowerBIXMLA.PowerBIXMLADataAdapter($sql, $conn) $dt= New-Object System.Data.DataTable $da.Fill($dt) $dt.Rows | foreach { Write-Host $ $ }