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

The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now! Learn more

Reply
Andrea_CS
New Member

PowerBi cmdlets for Powershell - Error Acquiring Token

Hi all,
I would like to execute some basic commands using PowerBi cmdlets for Powershell. I have installed these modules on PowerShell:

 

MicrosoftPowerBIMgmt
MicrosoftPowerBIMgmt.Admin
MicrosoftPowerBIMgmt.Capacities
MicrosoftPowerBIMgmt.Data
MicrosoftPowerBIMgmt.Profile
MicrosoftPowerBIMgmt.Reports
MicrosoftPowerBIMgmt.Workspaces

 

When using "Connect-PowerBIServiceAccount" the login screen for my organization comes up and I login correctly using my credentials.

Once the connection is established i need to execute these simple calls: "Get-PowerBIWorkspace" and "Get-PowerBIReport" but I get this error:

 

Message : Error Acquiring Token:
The WriteObject and WriteError methods cannot be called from outside the overrides of the BeginProcessing, ProcessRecord, and EndProcessing methods, and
they can only be called from within the same thread. Validate that the cmdlet makes these calls correctly, or contact Microsoft Customer Support Services.
StackTrace : in Microsoft.PowerBI.Common.Authentication.WindowsAuthenticationFactory.<HandleAuthentication>d__3.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
in System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
in System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
in Microsoft.PowerBI.Common.Authentication.WindowsAuthenticationFactory.<Authenticate>d__1.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
in System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
in System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
in Microsoft.PowerBI.Commands.Common.AuthenticationFactorySelector.<Authenticate>d__5.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
in System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
in System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
in Microsoft.PowerBI.Commands.Common.AuthenticationFactorySelector.<Authenticate>d__7.MoveNext()
Exception : System.Security.Authentication.AuthenticationException
InvocationInfo : {Get-PowerBIWorkspace}
Line : Get-PowerBIWorkspace
Position : line:1 char:1
+ Get-PowerBIWorkspace
+ ~~~~~~~~~~~~~~~~~~~~
HistoryId : 7

 

I have full permissions in Azure Active Directory and PowerBi Service Account. Please any ideas how to solve this issue?

 

Thank you

1 REPLY 1
Anonymous
Not applicable

Hi @Andrea_CS ,

 

Please check your environments and PowerShell versions.

  • Windows PowerShell v3.0 and up with .NET 4.7.1 or above.
  • PowerShell Core (v6) and up on any OS platform supported by PowerShell Core.

For reference: Microsoft Power BI Cmdlets for Windows PowerShell and PowerShell Core

 

Best Regards,
Rico Zhou

 

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

Helpful resources

Announcements
Power BI DataViz World Championships

Power BI Dataviz World Championships

The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now!

December 2025 Power BI Update Carousel

Power BI Monthly Update - December 2025

Check out the December 2025 Power BI Holiday Recap!

FabCon Atlanta 2026 carousel

FabCon Atlanta 2026

Join us at FabCon Atlanta, March 16-20, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.