Control Outlook AutoDiscover using registry and PowerShell

Controlling the behavior of Outlook AutoDiscover using the registry is not a new idea. Indeed, it has been around almost as long as AutoDiscover itself—perhaps longer.

If you are unfamiliar with the technique, essentially what we can do is tell Outlook to ignore, or only use, a certain part of the AutoDiscover process. We can use this to good effect in Active Directory environments where an on-premises Exchange environment still exists, but where you may wish to configure an email profile outside of that.

AutoDiscover can use something called Service Connection Point (SCP), which can interrupt or take precedence over externally published DNS information. This is especially true when an organization may be switching from a local Exchange environment to Office 365.

In addition to this, which you can have a relative amount of control over, another situation may arise that requires you to override the AutoDiscover process manually. I speak of course of the externally hosted website.

This situation is relevant for at least two of my clients, one using Office 365, the other still using an Exchange 2010 environment, and I have no reason to think I am alone in this.

The scenario is that the web server a client has their public website running on also accepts IMAP connections. When this is true, and you attempt to AutoDiscover an Outlook account to your Exchange Server, AutoDiscover will find the IMAP service at the root of the domain. It will then attempt to configure Outlook to talk to that instead of moving on to talk to your Exchange Server.

The solution for this is to use the registry to control Outlook's behavior, and the method I have used is to set the PreferLocalXML DWORD entry. Configuring this requires setting at least two registry entries and creating an XML file, which has to contain the AutoDiscover URL for that specific domain.

For example if your domain was using Office 365, your XML may look like this:

Or for another domain name, it may look like this:

Never one to shy away from the chance to automate something, I created a small script to do this for me. The script takes input in the form of a domain name, configures the PreferLocalXML DWORD, the REG_SZ (string) for the domain name, and sets up the XML file.

It also then sets up the other registry entries and disables the ones we do not want to use, leaving only PreferLocalXML, HTTPRedirect, and HTTPSAutoDiscoverDomain enabled.

Configure AutoDiscover in the registry

Configure AutoDiscover in the registry

This script runs in the logged-on user's context and is per user. If you have multiple people sharing the same computer, you would need to run it for all of them. However, it will not recreate the XML file if it is already present.

The last thing to mention is the path where these registry edits occur. This relates to the version of Office installed on your computer.

Using a query, we can determine all the versions installed based on their version number. Then we select the newest version and make our AutoDiscover edits for that version only.

Of course, making a few registry edits is trivial, and even creating an XML file would take a few seconds. But using this script allows me to set up the settings quickly and correctly each time with minimal effort.

Join the 4sysops PowerShell group!

Your question was not answered? Ask in the forum!

  1. Darren 6 months ago

    i get this output 


    how do i correct the issue ?


    Office Version : 16.0
    An Error Occurred
    Cannot find path 'HKCU:\SOFTWARE\Microsoft\Office\16.0\Outlook\AutoDiscover' because it does not exist.




  2. Adam 2 months ago

    This script is helpful, thank you. 

    For anyone who is migrating to O365, but have yet to cut over DNS records then add the following registry entry in addition to the script edits. 



Leave a reply

Your email address will not be published. Required fields are marked *


© 4sysops 2006 - 2020


Please ask IT administration questions in the forums. Any other messages are welcome.


Log in with your credentials


Forgot your details?

Create Account