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

Enhance your career with this limited time 50% discount on Fabric and Power BI exams. Ends August 31st. Request your voucher.

Reply
vrocca
Advocate IV
Advocate IV

Using Get-PowerBIWorkspace PowerShell command

This may be a simple/dumb question, but I'm trying to get a list of Workspaces using PowerShell, and I'm getting an error "Attempted to access an element as a type incompatible with the array"

Error.png

 

 

What am I doing wrong?

 

Thanks,
Victor Rocca | www.victorrocca.com
6 REPLIES 6
kayu
Microsoft Employee
Microsoft Employee

Hi Victor, would you be so kind to head over to the githup repo of the cmdlets and file this as an issue under: https://github.com/Microsoft/powerbi-powershell/issues? I've seen this error before but it went away after I updated .NET and Powershell. Hope this helps.

Cheers,

Kay

Thanks Kay.

 

I have PSVersion 5.1 and .NET Framework 4.7. Do you have something different?

Thanks,
Victor Rocca | www.victorrocca.com

It looks like the issue was being caused by a Newtonsoft.Json conflict. 

 

"The issue is likely due to a mismatch in Newtonsoft.Json between the Power BI cmdlets and some other cmdlets loaded into PowerShell session (via profile or calling directly)"

 

More info here: https://github.com/Microsoft/powerbi-powershell/issues/60

 

Current workaround is to use Powershell Core

Thanks,
Victor Rocca | www.victorrocca.com
timmac
Microsoft Employee
Microsoft Employee

I was battling this error as well.  However, I was able to get by it by using a user that is a Global Administrator.  I would suggest double checking that as well.

 

 

it's a bit of a necro-thread reply, however i was able to work out what was going on...

 

Essentially it seems that Powershell only loads one version of each DLL (per session), no matter how many modules you are referencing it from. This of course makes perfect sense - UNTIL you first reference a module which uses an "old" version of newtonsoft.json.dll (I did a search, and had >50 newtonsoft.json.dll files on my PC with many different versions).

 

So the trick is, at the start of a Powershell session make sure you load a module which references a new enough version of the newtonsoft DLL

 

this did the trick for me. 

 

 

 

if (Get-Module -Name MicrosoftPowerBIMgmt -ListAvailable) 
    {
    Import-Module MicrosoftPowerBIMgmt -ErrorAction SilentlyContinue #workaround
    }

 

 

kayu
Microsoft Employee
Microsoft Employee

Hi Victor, would you be so kind to head over to the githup repo of the cmdlets and file this as an issue under: https://github.com/Microsoft/powerbi-powershell/issues? I've seen this error before but it went away after I updated .NET and Powershell. Hope this helps.

Cheers,

Kay

Helpful resources

Announcements
July 2025 community update carousel

Fabric Community Update - July 2025

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

July PBI25 Carousel

Power BI Monthly Update - July 2025

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

Join our Fabric User Panel

Join our Fabric User Panel

This is your chance to engage directly with the engineering team behind Fabric and Power BI. Share your experiences and shape the future.