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

July 7 - July 17 | Round 2 of the Power BI Dataviz World Championships. Don't miss your chance! Learn more

Reply
Anonymous
Not applicable

Invoke-ASCmd (PowerShell) - 'Cannot find table' When Name Has Space

Hi. After a few hours of searching, I'm hopeful that someone can point me in the right direction. I've got a simple PowerShell script that connects to an endpoint and runs a simple DAX query (ex: "EVALUATE (<mytable>)". The command works perfectly fine when the table name doesn't have a space; but it fails when it does:

 

WORKS: [xml]$resp = Invoke-ASCmd -Query "EVALUATE (<mytable>)" -Server "powerbi://api.powerbi.com/v1.0/myorg/myorg" -Database "MyDb"  -Verbose

 

FAILS: [xml]$resp = Invoke-ASCmd -Query "EVALUATE ('<another table>')" -Server "powerbi://api.powerbi.com/v1.0/myorg/anotherorg" -Database "AnotherDB"  -Verbose

 

I've tried enclosing the table name in different quoting variations with no success. I've also run the same DAX query (with single quotes around the table name) in PowerBI desktop and everything is fine.  PowerShell version didn't impact anything (tried with both 5.1 & 7). It should work; but it just doesn't.

 

Any guidance from the community would be appreciated. 

 

Thanks!

3 REPLIES 3
Anonymous
Not applicable

I inheritied a project from a former employee and was just following their approach. The hope was to use the same approach (which works on tables without spaces); rather than redo the code. 

Redo the code. You will see better performance too.

lbendlin
Super User
Super User

Why Invoke-ASCmd?  Why not  Invoke-PowerBIRestMethod ?

Helpful resources

Announcements
FabCon and SQLCon Barcelona 2026

FabCon & SQLCon – Barcelona 2026

Join us in Barcelona for FabCon and SQLCon, the Fabric, Power BI, SQL, and AI community event. Save €200 with code FABCMTY200.

60 days of Data Days Carousel

Data Days 2026

Join Fabric Data Days 2026: 60 days of free live/on-demand sessions, challenges, study groups, and certification opportunities.

Power BI DataViz World Championships carousel

Power BI DataViz World Championships - June 2026

A new Power BI DataViz World Championship is coming this June! Don't miss out on submitting your entry.

Top Solution Authors