Created
October 4, 2022 20:23
-
-
Save bill-long/e57d70355a5eb680d8bfaf68d11b6869 to your computer and use it in GitHub Desktop.
Super simple AutoDiscover test. Does not attempt to encapsulate all of Outlook's logic.
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
[CmdletBinding()] | |
param ( | |
[Parameter()] | |
[string] | |
$HostName, | |
[Parameter()] | |
[string] | |
$EmailAddress | |
) | |
$body = '<?xml version="1.0" encoding="utf-8"?><Autodiscover xmlns="http://schemas.microsoft.com/exchange/autodiscover/outlook/requestschema/2006"><Request><EMailAddress>' + $EmailAddress + '</EMailAddress><AcceptableResponseSchema>http://schemas.microsoft.com/exchange/autodiscover/outlook/responseschema/2006a</AcceptableResponseSchema></Request></Autodiscover>' | |
$response = Invoke-WebRequest "https://$HostName/autodiscover/autodiscover.xml" -Method POST -ContentType "text/xml" -Body $body -UseDefaultCredentials | |
if ($response.StatusCode -eq 200) { | |
$response.Content | |
} else { | |
$response | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment