Forum Discussion
chad-at-danaher
Jul 12, 2023Copper Contributor
Error connecting to ExchangeOnline with PowerShell 7 - "Error Acquiring Token:...."
I can connect to EXO with PowerShell 5.1 fine. I just installed PS 7.3.5. When I run Connect-ExchangeOnline I get the following error: PS C:\> Connect-ExchangeOnline Error Acquiring Token: Syst...
Alexterneuzen
Jul 12, 2023Copper Contributor
You can try also:
Import-module ExchangeOnlineManagement -usewindowspowershell
Import-module ExchangeOnlineManagement -usewindowspowershell
- ftapnNov 13, 2024Copper Contributor
wow that worked, thank you.
i had something similar. i put here the details, to help others with same problems finding this solution.
ExO tried to open a link instead of a login screenhttps://localhost:58964/?code=.....
with ERR_CONNECTION_REFUSED. then nothing happens.
i had to CTRL+C to kill the prossess. than this error appears:PS > Connect-ExchangeOnline -UserPrincipalName email address removed for privacy reasons Error Acquiring Token: System.OperationCanceledException: The operation was canceled. at System.Threading.CancellationToken.ThrowOperationCanceledException() at System.Threading.CancellationToken.ThrowIfCancellationRequested() at Microsoft.Identity.Client.Platforms.Shared.DefaultOSBrowser.HttpListenerInterceptor.ListenToSingleRequestAndRespondAsync(Int32 port, String path, Func`2 responseProducer, CancellationToken cancellationToken) at Microsoft.Identity.Client.Platforms.Shared.Desktop.OsBrowser.DefaultOsBrowserWebUi.InterceptAuthorizationUriAsync(Uri authorizationUri, Uri redirectUri, Boolean isBrokerConfigured, CancellationToken cancellationToken) at Microsoft.Identity.Client.Platforms.Shared.Desktop.OsBrowser.DefaultOsBrowserWebUi.AcquireAuthorizationAsync(Uri authorizationUri, Uri redirectUri, RequestContext requestContext, CancellationToken cancellationToken) at Microsoft.Identity.Client.Internal.AuthCodeRequestComponent.FetchAuthCodeAndPkceInternalAsync(IWebUI webUi, CancellationToken cancellationToken) at Microsoft.Identity.Client.Internal.AuthCodeRequestComponent.FetchAuthCodeAndPkceVerifierAsync(CancellationToken cancellationToken) at Microsoft.Identity.Client.Internal.Requests.InteractiveRequest.GetTokenResponseAsync(CancellationToken cancellationToken) at Microsoft.Identity.Client.Internal.Requests.InteractiveRequest.ExecuteAsync(CancellationToken cancellationToken) at Microsoft.Identity.Client.Internal.Requests.RequestBase.<>c__DisplayClass11_1.<<RunAsync>b__1>d.MoveNext() --- End of stack trace from previous location --- at Microsoft.Identity.Client.Utils.StopwatchService.MeasureCodeBlockAsync(Func`1 codeBlock) at Microsoft.Identity.Client.Internal.Requests.RequestBase.RunAsync(CancellationToken cancellationToken) at Microsoft.Identity.Client.ApiConfig.Executors.PublicClientExecutor.ExecuteAsync(AcquireTokenCommonParameters commonParameters, AcquireTokenInteractiveParameters interactiveParameters, CancellationToken cancellationToken) at Microsoft.Exchange.Management.AdminApiProvider.Authentication.MSALTokenProvider.GetAccessTokenAsync(String claims, String cmdletId)
doing your solution i get:
PS > Import-module ExchangeOnlineManagement -usewindowspowershell WARNING: Module ExchangeOnlineManagement is loaded in Windows PowerShell using WinPSCompatSession remoting session; please note that all input and output of commands from this module will be deserialized objects. If you want to load this module into PowerShell please use 'Import-Module -SkipEditionCheck' syntax.
and than it works.
--
this fix was for ExO v2, cause it didnt support PS7. looks like there is some incompatibility issues again, now between ExO v3 and PS7. here are my versions:PS > $PSVersionTable Name Value ---- ----- PSVersion 7.4.6 PSEdition Core GitCommitId 7.4.6 OS Microsoft Windows 10.0.19045 Platform Win32NT PSCompatibleVersions {1.0, 2.0, 3.0, 4.0…} PSRemotingProtocolVersion 2.3 SerializationVersion 1.1.0.1 WSManStackVersion 3.0 PS > Get-Module ExchangeOnlineManagement ModuleType Version PreRelease Name ExportedCommands ---------- ------- ---------- ---- ---------------- Script 3.6.0 ExchangeOnlineManagement {Add-VivaModuleFeaturePolicy, Get-ConnectionInfor… Script 1.0 ExchangeOnlineManagement {Add-VivaModuleFeaturePolicy, Connect-ExchangeOnl… PS > Get-InstalledModule Version Name Repository Description ------- ---- ---------- ----------- 3.6.0 ExchangeOnlineManagement PSGallery This is a General Availability (GA) rele… 1.0.6 Microsoft.PowerShell.PSResourceGet PSGallery PowerShell module with commands for disc… 2.2.5 PowerShellGet PSGallery PowerShell module with commands for disc…