Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

Score big with last-minute savings on the final tickets to FabCon Vienna. Secure your discount

Reply
Alibek
Frequent Visitor

Connecting to PowerBI Dataset from a PS Script: "The Connection String is not valid"

Hello!
When I try to connect to Power BI Dataset from Powershell Script, I get the following error:

 

Exception calling "Connect" with "1" argument(s): "The connection string is not valid."
At line:1 char:1
+ $serverConn.connect($connectionString)
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : NotSpecified: (:) [], MethodInvocationException
+ FullyQualifiedErrorId : ConnectionException

 

Code that I used:

$serverConn = New-Object Microsoft.AnalysisServices.Tabular.Server
$connectionString='Data source=powerbi://api.powerbi.com/v1.0/myorg/<workspace name>;Catalog=<dataset name>;User ID=<username>;Password=<password>'
$serverConn.Connect($connectionString)
1 ACCEPTED SOLUTION
Martin_D
Super User
Super User

Hi @Alibek ,

Write "Cube" instead of "Catalog", see reference: https://learn.microsoft.com/en-us/analysis-services/instances/connection-string-properties-analysis-...

Make sure all other preconditions for enabling the XMLA API are met, including using a Premium workspace, having XMLA access enabled in the tenant settings and make sure the user has the necessary privileges.

In the Power BI CmdLets there is not relly support for XMLA access except the generic Invoke-PowerBIRestMethod in combination with the executeQueries REST Method. But this can only execute DAX queries and not XMLA calls like refreshing a single partition or creating a calculation group.

BR

Martin

github.pnglinkedin.png

View solution in original post

2 REPLIES 2
Martin_D
Super User
Super User

Hi @Alibek ,

Write "Cube" instead of "Catalog", see reference: https://learn.microsoft.com/en-us/analysis-services/instances/connection-string-properties-analysis-...

Make sure all other preconditions for enabling the XMLA API are met, including using a Premium workspace, having XMLA access enabled in the tenant settings and make sure the user has the necessary privileges.

In the Power BI CmdLets there is not relly support for XMLA access except the generic Invoke-PowerBIRestMethod in combination with the executeQueries REST Method. But this can only execute DAX queries and not XMLA calls like refreshing a single partition or creating a calculation group.

BR

Martin

github.pnglinkedin.png

Anonymous
Not applicable

HI @Alibek,

I'd like to suggest you use powershell cmdlet model to handle and operate with power bi service contents.

Power BI Cmdlets reference | Microsoft Learn
Regards,

Xiaoxin Sheng

Helpful resources

Announcements
August Power BI Update Carousel

Power BI Monthly Update - August 2025

Check out the August 2025 Power BI update to learn about new features.

August 2025 community update carousel

Fabric Community Update - August 2025

Find out what's new and trending in the Fabric community.