Pro-Exchange,Lync & Office 365
Belgian Microsoft Unified Communications Professionals
Microsoft Exchange Server, Microsoft Lync Server & Office 365
Retrieving Exchange Autodiscover SCP information from AD via PowerShell

As part of the Autodiscover process, Outlook will query Active Directory in search for the Autodiscover SCP which it will use to discover the Autodiscover URL where it should send its request to. The configuration information for Autodiscover can easily be retrieved with the Get-ClientAccessServer cmdlet, which will show you important information like:

  • AutoDiscoverSiteScope
  • AutoDiscoverServiceInternalUri
  • WhenCreated

The reason that I'm referring to these three items is because of the way Outlook will handle the retrieved Autodiscover information. In a nutshell, it will query AD and will retrieve a list of SCPs. This list will first be ordered based on the Site Scope (the site in which the client resides). If not, the list will be ordered by creation date (older entries will get queried first).

If you wish to find out more about this process, have a look at the following article: http://technet.microsoft.com/en-us/library/bb332063(v=exchg.80).aspx

What I wanted to do, is "mimic" this process without running the Get-ClientAccessServer cmdlet. One of the reasons is that Get-ClientAccessServer cmdlet depends on the Exchange Management Shell (or more accurately, the Exchange snapin).

Below you will find a code example which uses PowerShell's ability to query AD directly (ADSI). It will use exactly the same query as Outlook does to retrieve a list of SCPs and will then query these SCPs for the information mentioned above. In the end, the information is displayed on screen, where the SCP records are filtered based on SiteScope and Creation date. This should give you a pretty good idea of what URL/server your Outlook client will connect to (first) during the AutoDiscover process. Enjoy!

$obj = @()


$ADDomain = Get-ADDomain | Select DistinguishedName
$DSSearch = New-Object System.DirectoryServices.DirectorySearcher
$DSSearch.Filter = '(&(objectClass=serviceConnectionPoint)(|(keywords=67661d7F-8FC4-4fa7-BFAC-E1D7794C1F68)(keywords=77378F46-2C66-4aa9-A6A6-3E7A48B19596)))'
$DSSearch.SearchRoot = 'LDAP://CN=Configuration,'+$ADDomain.DistinguishedName
$DSSearch.FindAll() | %{
    $ADSI = [ADSI]$_.Path
    $autodiscover = New-Object psobject -Property @{
        Server = [string]$ADSI.cn
        Site = $adsi.keywords[0]
        DateCreated = $adsi.WhenCreated.ToShortDateString()
        AutoDiscoverInternalURI = [string]$adsi.ServiceBindingInformation
    }
    $obj += $autodiscover
}
Write-Output $obj | Select Server,Site,DateCreated,AutoDiscoverInternalURI | ft -AutoSize


Posted 11-21-2012 9:11 by Michael Van Horenbeeck