Created
January 9, 2026 13:50
-
-
Save Apoc70/7ba2e2bf7b5d9bcd90bd128cf9aad652 to your computer and use it in GitHub Desktop.
Helper script to query Exchange AutoDiscover v2 endpoints
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| param( | |
| [Parameter(Mandatory = $true)] | |
| [string]$Email, # Email address to query AutoD for | |
| [Parameter(Mandatory = $true)] | |
| [ValidateSet('EWS', 'ActiveSync', 'Rest')] # Protocol to use | |
| [string]$Protocol, | |
| [string]$Server = 'outlook.office365.com' # Default to Office 365, use another server if needed | |
| ) | |
| $uri = "https://$Server/autodiscover/autodiscover.json?Email=$Email&Protocol=$Protocol" | |
| try { | |
| $result = Invoke-RestMethod -Uri $uri -Headers @{ 'Accept' = 'application/json' } -TimeoutSec 30 | |
| Write-Host "Queried: $uri" -ForegroundColor Cyan | |
| $result | |
| } | |
| catch { | |
| Write-Warning "Failed to query AutoD for $Email using $Protocol. Error: $_" | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment