Autodiscover v2 (JSON) & Microsoft Graph Endpoint Discovery: Retiring Legacy EWS AutodiscoverUrl in PowerShell

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:

  1. 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.
  2. 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-RestMethod callβ€”no Microsoft.Exchange.WebServices.dll or 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.


Legacy POX/SOAP Autodiscover v1 vs. Modern Autodiscover v2 & Graph Routing Legacy: EWS AutodiscoverUrl() (v1 XML/SOAP) 1. Queries AD SCP records (unless EnableSCPLookup=false) 2. Probes https://domain.com/autodiscover/autodiscover.xml 3. Follows 302 redirect via RedirectionUrlValidationCallback 4. Requires Basic/OAuth credentials on every probe Slow (multiple round-trips) & prone to root-domain hangs Modern: Autodiscover v2 JSON & Microsoft Graph 1. Cloud Mailboxes: Direct call to graph.microsoft.com/v1.0 2. Hybrid Discovery: Single GET to autodiscover.json/v1.0/{upn} 3. Unauthenticated JSON response in <150ms 4. Returns Protocol Url (EWS, REST, ActiveSync, Autodiscoverv1) Zero DLL dependencies Β· Native PowerShell Invoke-RestMethod Verified live against the LAB 365 tenant (outlook.office365.com/autodiscover/autodiscover.json).

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:

TEXT
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]):

POWERSHELL
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):

TEXT
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 (when RedirectCount=3 is 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.
POWERSHELL
# 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:

POWERSHELL
# 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:

POWERSHELL
# 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.