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)

Most upvoted comments

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,

  1. Click on Start
  2. Run
  3. PowerShell_ISE.exe -noprofile

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?

PS C:\WINDOWS\system32> Login-PowerBI


Environment : Public
TenantId    : 945c199a-83a2-4e80-9f8c-5a91be5752dd
UserName    : Ethan_Hammond@DELL.com



PS C:\WINDOWS\system32> Get-PowerBIActivityEvent -StartDateTime '2022-03-24' -EndDateTime '2022-03-25'
Get-PowerBIActivityEvent : Attempted to access an element as a type incompatible with the array.
At line:1 char:1
+ Get-PowerBIActivityEvent -StartDateTime '2022-03-24' -EndDateTime '20 ...
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : WriteError: (Microsoft.Power...BIActivityEvent:GetPowerBIActivityEvent) [Get-PowerBIActi
   vityEvent], ArrayTypeMismatchException
    + FullyQualifiedErrorId : Attempted to access an element as a type incompatible with the array.,Microsoft.PowerBI.
   Commands.Admin.GetPowerBIActivityEvent

@CattieCat Can you provide an example of how to use the REST API?