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

We've captured the moments from FabCon & SQLCon that everyone is talking about, and we are bringing them to the community, live and on-demand. Starts on April 14th. Register now

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
New to Fabric survey Carousel

New to Fabric Survey

If you have recently started exploring Fabric, we'd love to hear how it's going. Your feedback can help with product improvements.

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.

Join our Fabric User Panel

Join our Fabric User Panel

Share feedback directly with Fabric product managers, participate in targeted research studies and influence the Fabric roadmap.

March Power BI Update Carousel

Power BI Community Update - March 2026

Check out the March 2026 Power BI update to learn about new features.