powerbi-powershell: Get-PowerBIWorkspace : Attempted to access an element as a type incompatible with the array.
When I run the example code from https://docs.microsoft.com/en-us/powershell/power-bi/overview?view=powerbi-ps
Login-PowerBIServiceAccount
Get-PowerBIWorkspace
I get the error
Get-PowerBIWorkspace : Attempted to access an element as a type incompatible with the array.
At line:2 char:1
+ Get-PowerBIWorkspace
+ ~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : WriteError: (Microsoft.Power...owerBIWorkspace:GetPowerBIWorkspace) [Get-PowerBIWorkspace], ArrayTypeMismatchException
+ FullyQualifiedErrorId : Attempted to access an element as a type incompatible with the array.,Microsoft.PowerBI.Commands.Workspaces.GetPowerBIWorkspace
There was a similar issue (#60) that was marked as closed with a note to update .NET but I am running the current version and still get this erro
About this issue
- Original URL
- State: closed
- Created 6 years ago
- Comments: 28 (4 by maintainers)
Hey @parag1231 - I had the same issue using the current (as of now) version of MicrosoftPowerBIMgmt i.e. 1.0.867, however following the -noprofile has worked for me in PowerShell ISE too. Try the below steps, hopefully should work for you as well,
Randomly stuck at this error again. Nothing above fixes it. Customer furious because I can’t run this script to update our system. 🙄
Edit: upgrading powershell from 7.2.6 to 7.2.7 fixed it for me.
2022 with the same bug using 1.2.1077… -noprofile doesn’t work. The following allows me to login (again, using -noprofile and not using -noprofile to launch powershell) but the next command fails.
Windows 10
How has this issue not been resolved in 4 years, and closed? Should I open a new bug on this?
@CattieCat Can you provide an example of how to use the REST API?
Our official walkaround: