In Part 3 of our original 2014 EWS Managed API series, we used $service.AutodiscoverUrl('[email protected]', {$true}) with EnableSCPLookup = $false to follow XML redirections to https://autodiscover-s.outlook.com/autodiscover/autodiscover.xml and locate a user's EWS endpoint.
In 2026, two major architectural shifts have transformed endpoint discovery in Exchange Online and Hybrid deployments:
- Microsoft Graph uses a single global endpoint (
https://graph.microsoft.com/v1.0): Cloud mailbox scripts no longer need Autodiscover to find a mailbox server URL. Graph routes requests to the user's mailbox substrate automatically based on the user's UPN or Object ID. - Autodiscover v2 (REST/JSON) has replaced legacy XML/SOAP probing for hybrid discovery: When you need to determine whether a mailbox is hosted in Exchange Online or on-premises Exchange Server SE (or obtain its EWS, REST, or ActiveSync endpoint), you query the unauthenticated Autodiscover v2 JSON endpoint via a single
Invoke-RestMethodcallβnoMicrosoft.Exchange.WebServices.dllor user credentials required.
This guide shows how Autodiscover v2 works, live-tested PowerShell functions to discover endpoints across hybrid domains, and how to retire legacy $service.AutodiscoverUrl() calls.
1. Live-Tested: Querying Autodiscover v2 (JSON) in PowerShell
Unlike Autodiscover v1 (which required authenticated XML POST requests to /autodiscover/autodiscover.xml or /autodiscover/autodiscover.svc), Autodiscover v2 exposes a lightweight, unauthenticated GET endpoint:
https://outlook.office365.com/autodiscover/autodiscover.json/v1.0/<email>?Protocol=<Protocol>
We ran the following script live against our LAB 365 Dev Tenant ([email protected]):
function Test-AutodiscoverV2Endpoint {
[CmdletBinding()]
param(
[Parameter(Mandatory = $true)]
[string]$EmailAddress,
[string[]]$Protocols = @("REST", "EWS", "ActiveSync", "Autodiscoverv1")
)
foreach ($proto in $Protocols) {
$uri = "https://outlook.office365.com/autodiscover/autodiscover.json/v1.0/$($EmailAddress)?Protocol=$proto&RedirectCount=3"
try {
$resp = Invoke-RestMethod -Method Get -Uri $uri -ErrorAction Stop
[PSCustomObject]@{
EmailAddress = $EmailAddress
Protocol = $resp.Protocol
EndpointUrl = $resp.Url
Status = "Resolved"
}
} catch {
[PSCustomObject]@{
EmailAddress = $EmailAddress
Protocol = $proto
EndpointUrl = $null
Status = "Failed: $($_.Exception.Message)"
}
}
}
}
Test-AutodiscoverV2Endpoint -EmailAddress "[email protected]" | Format-Table -AutoSize
Live Lab Output (xzf58.onmicrosoft.com):
EmailAddress Protocol EndpointUrl Status
------------ -------- ----------- ------
[email protected] REST https://outlook.office.com/api Resolved
[email protected] EWS https://outlook.office365.com/EWS/Exchange.asmx Resolved
[email protected] ActiveSync https://outlook.office365.com/Microsoft-Server-ActiveSync Resolved
[email protected] Autodiscoverv1 https://autodiscover-s.outlook.com/autodiscover/autodiscover.xml Resolved
TIP:
Notice how fast and clean this is: if a mailbox is located on-premises in a hybrid organization, Exchange Online's Autodiscover v2 endpoint automatically follows the hybrid domain's on-premises Autodiscover record (whenRedirectCount=3is specified) and returns the on-premises Exchange Server SE endpoint URL!
2. Why Microsoft Graph Doesn't Need Autodiscover
When migrating your scripts from EWS Managed API to Microsoft Graph (see Part 1: Migrating EWS Managed API Scripts to Microsoft Graph SDK), you can delete your entire $service.AutodiscoverUrl() block.
In Microsoft Graph:
- Every cloud mailbox is addressed via
https://graph.microsoft.com/v1.0/users/{id-or-userPrincipalName}. - You never configure a server URL or a redirection callback.
# Legacy EWS (DELETE THIS):
# $service.EnableSCPLookup = $false
# $service.AutodiscoverUrl('[email protected]', {$true})
# Modern Microsoft Graph (Single Global Endpoint):
Connect-MgGraph -TenantId $TenantId -ClientId $ClientId -CertificateThumbprint $Thumbprint -NoWelcome
Get-MgUser -UserId "[email protected]" -Property Id, DisplayName, Mail, UserPrincipalName
3. Troubleshooting On-Premises & Hybrid Autodiscover Redirections
If you still maintain on-premises Exchange Server SE or a hybrid environment where Outlook clients or hybrid Free/Busy lookups fail Autodiscover:
1. Verify On-Premises SCP (Service Connection Point) in Active Directory
Domain-joined Outlook clients query Active Directory first for the ServiceBindingInformation attribute on each Exchange server's SCP object. In a hybrid migration where most mailboxes are in Exchange Online, ensure your SCP points to a valid load-balanced HTTPS namespace with a trusted TLS certificate:
# Run in on-premises Exchange Management Shell (EMS)
Get-ClientAccessService |
Select-Object Name, AutoDiscoverServiceInternalUri, AutoDiscoverSiteScope |
Format-Table -AutoSize
2. Block Outlook Root-Domain Autodiscover Delays
Before probing autodiscover.yourdomain.com, Outlook historically checked https://yourdomain.com/autodiscover/autodiscover.xml. If your public marketing website (yourdomain.com) drops or hangs on that path instead of returning an instant HTTP 404, Outlook freezes for 30β60 seconds during profile setup. Deploy the Group Policy / Intune registry key to disable root-domain probing:
# Disable root domain Autodiscover lookup on Outlook clients
$regPath = "HKCU:\Software\Microsoft\Office\16.0\Outlook\AutoDiscover"
if (-not (Test-Path $regPath)) { New-Item -Path $regPath -Force | Out-Null }
Set-ItemProperty -Path $regPath -Name "ExcludeHttpsRootDomain" -Value 1 -Type DWord
π¬ Reader Comments & Feedback
Did this runbook help, or did Microsoft change a cmdlet or UI menu? Share your feedback below.
Leave a Comment or Report an Update