Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
# Syntax:
# Test-EWSEndpoints
Import-Module -Name "C:\Program Files\Microsoft\Exchange\Web Services\2.2\Microsoft.Exchange.WebServices.dll"
$urls = New-Object 'System.Collections.Generic.List[string]'
# Update these URLs to reflect the URLs you want to test
foreach ($url in $urls)
$exchService = new-object Microsoft.Exchange.WebServices.Data.ExchangeService([Microsoft.Exchange.WebServices.Data.ExchangeVersion]::Exchange2010)
"Using EWS URL: " + $url
$exchService.Url = new-object System.Uri($url)
$exchService.UseDefaultCredentials = $true
$mbx = new-object Microsoft.Exchange.WebServices.Data.Mailbox($emailAddress)
$inboxFolderName = [Microsoft.Exchange.WebServices.Data.WellKnownFolderName]::Inbox
$inboxId = new-object Microsoft.Exchange.WebServices.Data.FolderId($inboxFolderName, $mbx)
try {
$inboxFolder = [Microsoft.Exchange.WebServices.Data.Folder]::Bind($exchService, $inboxId)
"Opened mailbox: " + $mbx
"Items in inbox: " + $inboxFolder.TotalCount
catch {
"Error. Could not open mailbox"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.