If you receive the following error when trying to connect to Exchange Online via PowerShell, then you will need to upgrade the Connect-ExchangeOnline PowerShell module.
AADSTS50011: The reply URL specified in the request does not match the reply URLs configured for the application

Resolving AADSTS50011 for Connect-ExchangeOnline
To resolve, launch PowerShell and run the following command. If you do not trust the PowerShell gallery you may also be prompted to confirm the installation from an untrusted gallery. Press “Y” to confirm.
C:\> Update-Module ExchangeOnlineManagement You are installing the module from an untrusted repository. If you trust this repository, change its InstallationPolicy value by running the Set-PSRepository cmdlet. Are you sure you want to install the module from 'PSGallery'? [Y] Yes [A] Yes to All [N] No to All [S] Suspend [?] Help: Y
At this point, it is best to close and reopen any PowerShell windows you had open and reissue the command Connect-ExchangeOnline. The issue should now be resolved.
Trusting the PSGallery
To validate whether you currently trust PSGallery, run the following command. In our example below we can see that the PSGallery is currently untrusted. The source location also identifies where the PowerShell repository is located. In this case www.powershellgallery.com.
C:\> Get-PSRepository -Name PSGallery Name InstallationPolicy SourceLocation ---- ------------------ -------------- PSGallery Untrusted https://www.powershellgallery.com/api/v2
Note: Although Microsoft operates www.powershellgallery.com, it is an open platform where any PowerShell author can upload their own scripts and modules. While we are trusting the repository at this website for our example, you should still heavily scrutinize any PowerShell script or module you download from the website.
For our example, we are going to trust the PSGallery repository. In this case, our command would be as follows.
C:\> Set-PSRepository PSGallery -InstallationPolicy Trusted
We can confirm our setting by reissuing the Get-PSRepository command.
C:\> Get-PSRepository Name InstallationPolicy SourceLocation ---- ------------------ -------------- PSGallery Trusted https://www.powershellgallery.com/api/v2

Have you run into this error before? What are your thoughts on trusting repositories? Drop a comment below or join the conversation on Twitter @SuperTekBoy.
Leave a Reply