If you are trying to connect to Exchange Online

and getting this error

Error Acquiring Token:
A window handle must be configured. See https://aka.ms/msal-net-wam#parent-window-handles
Here is the Solution:
- Aquire access token by using following script :
Important: RUN Each line separately!
$application = [Microsoft.Identity.Client.PublicClientApplicationBuilder]::Create("fb78d390-0c51-40cd-8e17-fdbfab77341b").WithDefaultRedirectUri().Build()
$result = $application.AcquireTokenInteractive([string[]]"https://outlook.office365.com/.default").ExecuteAsync().Result
Enter your SAML credentials for the Exchnage Online admin

2. Connect to Exchange Online by using access token with following command:
Connect-ExchangeOnline -AccessToken $result.AccessToken -UserPrincipalName $result.Account.Username

Leave a Reply