File tree Expand file tree Collapse file tree 1 file changed +15
-0
lines changed Expand file tree Collapse file tree 1 file changed +15
-0
lines changed Original file line number Diff line number Diff line change 1+ function Connect-ExchangeOnlineWorkaround {
2+ # Get a token and connect to Exchange Online
3+ # Inspired by https://david-homer.blogspot.com/2025/01/exchange-online-management-powershell.html
4+
5+ <# To Do:
6+ - Choose different environments to connect to
7+ - Add error handling
8+ #>
9+ $ExoMsalPath = [System.IO.Path ]::GetDirectoryName((Get-InstalledModule - Name ' ExchangeOnlineManagement' ).Path)
10+ Add-Type - Path " $ExoMsalPath \Microsoft.IdentityModel.Abstractions.dll"
11+ Add-Type - Path " $ExoMsalPath \Microsoft.Identity.Client.dll"
12+ [Microsoft.Identity.Client.IPublicClientApplication ] $ExoApplication = [Microsoft.Identity.Client.PublicClientApplicationBuilder ]::Create(' fb78d390-0c51-40cd-8e17-fdbfab77341b' ).WithDefaultRedirectUri().Build()
13+ $ExoAuthToken = $ExoApplication.AcquireTokenInteractive ([string []]' https://outlook.office365.com/.default' ).ExecuteAsync().Result
14+ Connect-ExchangeOnline - AccessToken $ExoAuthToken.AccessToken - UserPrincipalName $ExoAuthToken.Account.Username
15+ }
You can’t perform that action at this time.
0 commit comments