Forum Discussion
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
- AnonymousNot 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 ZhouIf this post helps, then please consider Accept it as the solution to help the other members find it more quickly.