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
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
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.

June 2025 community update carousel

Fabric Community Update - June 2025

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