Exchange Named Property Exhaustion

Sometimes a mailbox migration fails for reasons unrelated to mailbox size, corrupt items, or connectivity. We recently encountered this while migrating mailboxes from Exchange Server SE to Exchange Online. The migration of mailbox sharedbox1 failed with:

Cannot get ID from name. –> MapiExceptionNamedPropsQuotaExceeded: GetIdsFromNames operation has failed (hr=0x80040900, ec=-2147219200) 1.84300:0A000000, 1.84300:56000000, 1.73948:00000000, 5.71140:67000000446F526F70730000, 1.108572:00000000, 0.117068:090

The migration was stuck. Searching for MapiExceptionNamedPropsQuotaExceeded returns enough leads on the problem. In your search for an answer, you may have ended up on this article, or the CSS Exchange (Customer Support Services) site covering several scripts, that might solve this issue when your mailbox is in Exchange Online. There are a few scripts for Exchange Server, but they didn’t work or weren’t optimized, and they were more of a support tool than a user-friendly solution. So, while Exchange Online has CSS scripts, Exchange Server lacks a proper toolset to support analysis and remediation.

This gap led to the creation of ExchangeMEPTools, a PowerShell module that brings this functionality to Exchange Server. The goal was to offer the same cmdlets and process as the CSS support scripts for Exchange Online.

But first, what exactly are named properties, and how can a mailbox accumulate thousands of them completely out of sight?

Named Properties

Messages and other MAPI objects in a mailbox store information in properties. Applications can extend the predefined set using named properties, also called extended properties, to store custom data. Exchange maintains mappings for named properties within the mailbox, and those mappings are subject to quotas. Named properties also store metadata derived from Internet message headers. Microsoft explains the underlying limit here, noting that Outlook may also encounter quota issues.

This might become a silent killer when applications send messages using unique Internet headers. These aren’t necessarily your applications; external senders, or the applications they use, can also add the so-called X-headers to messages. Consider an application stamping 1,000 messages with:

X-MyApplication-TrackingId: <unique value>

There may be 1,000 different values, but there is still only one header name: X-MyApplication-TrackingId. Exchange can reuse the same named-property mapping.

Now put the unique identifier in the header name:

X-MyApplication-Attachment-<GUID>: <unique value>

Every GUID now produces a different header name:

X-MyApplication-Attachment-7f148c33-...
X-MyApplication-Attachment-c87e93dc-...
X-MyApplication-Attachment-41509641-...

Those aren’t different values of one property. They are different properties. If thousands of uniquely named headers are promoted to MAPI properties, the mailbox can consequently accumulate thousands of named-property mappings and eventually hit its quota. This set of named properties might be from last year, but it might also concern a mailbox that has been accumulating messages for decades. The latter is becoming less uncommon nowadays, especially with generic shared mailboxes such as info@<domain> without any retention applied whatsoever. So, this is the pattern we are going to look for and, perhaps, identify the cause.

With Exchange Server, you can increase the quota using Set-Mailbox with ExtendedPropertiesCountQuota. We strongly advise against that, as the quota is still a limit and would potentially only postpone problems to a later moment.

Exchange Mailbox Extended Property Tools

Exchange Online already offers cmdlets to investigate mailbox extended properties, including functionality corresponding to:

  • Get-MailboxExtendedProperty is a somewhat undocumented cmdlet that retrieves the named properties for a mailbox.
  • Test-MailboxExtendedProperty tests the retrieved properties against the applicable named-property quotas to identify where limits are being approached or exceeded.
  • Search-MailboxExtendedProperty searches the mailbox for items containing the selected named properties, mapping problematic properties back to the messages or other items on which they occur.
  • Remove-MailboxExtendedProperty removes the selected properties from those mailbox items, providing the actual remediation step.

Together, these cmdlets form a sequential cleanup flow: discovering, assessing, locating, and removing these named properties. Unlike Get-MailboxExtendedProperty, which is an Exchange Online cmdlet for retrieving named properties, the other three are CSS scripts using Microsoft Graph, so you must identify the extended properties before you can locate and remove them.

As stated earlier, Exchange Server doesn’t provide equivalent cmdlets for its on-premises mailboxes. We therefore created Exchange Mailbox Extended Property Tools (ExchangeMEPTools) to provide similar functionality for Exchange Server. Also, since Exchange Server doesn’t have Microsoft Graph, we leveraged the trusted, proven API, Exchange Web Services (EWS).

Requirements:

  • PowerShell 5.1 or later.
  • Exchange Management Shell for inventory and mailbox resolution. If the module detects that you are not running from Exchange Management Shell, the module attempts to locate the Exchange installation and loads the required Exchange functionality into the scope of the module.
  • Installed EWS.WebServices.Managed.API or its Microsoft.Exchange.WebServices.dll file residing in the current folder. This offers the required support for the mailbox-level operations.

ExchangeMEPTools is a PowerShell module available from the PowerShell Gallery. To install and load the module:

Install-Module ExchangeMEPTools
Import-Module ExchangeMEPTools

Now to the good stuff. After loading our module, we should have the following cmdlets at our disposal:

  • Get-MailboxExtendedProperty similar to CSS script.
  • Test-MailboxExtendedProperty similar to CSS script, but with an  ExchangeOnlineQuotas switch to make Test-MailboxExtendedProperty verify against the fixed quotas for Exchange Online.
  • Search-MailboxExtendedProperty similar to CSS script.
  • Remove-MailboxExtendedProperty similar to CSS script.
  • Connect-EWSSession to set up an EWS session to Exchange Server. It uses one session per specified identity during connection.
  • Disconnect-EWSSession to clear all EWS sessions.
  • Get-EWSSession to show details for a specific EWS session.

Start by inspecting a mailbox’s named properties. This uses Exchange cmdlets, so no need to connect to EWS at this stage:

Get-MailboxExtendedProperty -Identity sharedbox1@myexchangelabs.com | Test-MailboxExtendedProperty -ExchangeOnlineQuotas

This fetches the named properties for sharedbox1 using Exchange store cmdlets, then passes them through to start grouping and counting. We also specified ExchangeOnlineQuotas to verify the results against the Exchange Online quotas. For a test mailbox, the result was:

Output of Get-MailboxExtendedProperty

As in the Test-MailboxExtendedProperty script from CSS, we grouped named properties by the first 5 characters. As you can see, properties starting with “x-ziv” exceeded the quota. This means there are 2,431 unique properties, all starting with “x-ziv”. We may need more detailed information to identify the potential culprit and hint at the source of the issue. For this, we inspect the output of Get-MailboxExtendedProperty and look for clues. The PropertyName parameter accepts wildcards, so the command to fetch all properties starting with “x-ziv”, keep only the unique property names, and display the first 5 entries, is:

Get-MailboxExtendedProperty -PropertyName x-ziv* | Sort-Object -Property -Unique | select -first 5 PropertyName
PropertyName
------------
x-zivver-AddedAttachment
x-zivver-AddedAttachment-002e74c2-a4e2-4b88-99a3-6a36a9967fca
x-zivver-AddedAttachment-003ff7ad-8917-46e4-b579-784155a9506f
x-zivver-AddedAttachment-00845b32-2c37-4bd6-b076-9d9670357ae9
x-zivver-AddedAttachment-00e33eb4-ded8-49c7-8bed-c352499bb6ad

See the pattern? Apparently, Zivver, a platform many organizations use for secure email, adds internet headers to email messages to reference attachments. Which, of course, is fine unless you use GUIDs that make these headers unique. That could make you reach named property quotas real quick, or at least turn the quotas into a lurking issue.

Using the longer prefix confirmed it was the culprit:

Get-MailboxExtendedProperty -PropertyName x-zivver-addedattachment | Sort-Object -Property -Unique | measure-object

The result I got: 2,420 unique properties.

Cleaning Up

Now, before we can scan and remove these properties using our module, we need to authenticate to Exchange using EWS with Connect-EWSSession. The syntax of Connect-EWSSession using the most common parameters is:

Connect-EWSSession -Identity <Identity> -EwsUrl <url> -Credential <PSCredential> -UseDefaultCredentials -Impersonate -TrustAll
  • Identity is the mailbox to authenticate against. Needed when using Impersonation.
  • EwsUrl is used to override Autodiscover and set the endpoint for EWS operations.
  • Credential is a secure credential to use for authentication, e.g., fetched using Get-Credential.
  • UseDefaultCredentials is used when you want to use the current security context.
  • Impersonate should be specified when using Application Impersonation permissions.
  • TrustAll is to be used when you need to accept any certificate, including self-signed certificates.

When the connection is successful, we can start clearing mailbox items from those named properties. To achieve this, we need the output of Get-MailboxExtendedProperty. However, that output consists of named property-to-ID mappings, taken from the Exchange store. To process them, we also need to know the property type. We can add this to the output by adding the ResolvePropertyType switch. For this example, we will fetch the X-Zivver-AddedAttachment* properties and resolve them:

$properties= Get-MailboxExtendedProperty -Identity sharedbox1@myexchangelabs.com -PropertyName X-Zivver-AddedAttachment* -ResolvePropertyType

Do note that resolving adds time to fetching the property information. To show the resolution progress, Get-MailboxExtendedProperty displays a progress bar, including a resolution rate and a rough estimate of the time remaining.

The next step is to have the Search-MailboxExtendedProperty map the named properties collected by Get-MailboxExtendedProperty, and map them to the items within the mailbox:

$items= Search-MailboxExtendedProperty -MailboxExtendedProperty $properties

This requires crawling the mailbox. The time the search takes depends on how many properties Search-MailboxExtendedProperty has to match. A progress bar will display the folder being processed and the overall progress:

When all the mapping has been done, we can then put Remove-MailboxExtendedProperty to work by feeding Remove-MailboxExtendedProperty the results of the search:

Remove-MailboxExtendedProperty -MailboxExtendedProperty $items

Remove-MailboxExtendedProperty supports WhatIf if you first want to see what will happen. If you add the switch Passthru, Remove-MailboxExtendedProperty will return an object related to the item, such as Subject and FolderPath. To verify the result, specify the Verify switch to confirm removal.

The examples above use variables to pass data, which helps explain what happens at each step. The commands support pipeline operation, so discovery, searching, and removal can be combined in a single operation, e.g.

Get-MailboxExtendedProperty -Identity sharedbox1@myexchangelabs.com -PropertyName X-Zivver-AddedAttachment* -ResolvePropertyType | Search-MailboxExtendedProperty | Remove-MailboxExtendedProperty

Also, you can store the intermediate results in external files for inspection, and read those files for the next step, e.g.

$props= Get-MailboxExtendedProperty -Identity sharedbox1@myexchangelabs.com -ResolvePropertyType
$props | ConvertTo-Json | Set-Content .\sharedbox1-properties.json

$props= Get-Content .\sharedbox1-properties.json -Raw | ConvertFrom-Json
$items= $props | Search-MailboxExtendedProperty
$items | ConvertTo-Json | Set-Content .\sharedbox1-items.json

$items = Get-Content .\sharedbox1-items.json -Raw | ConvertFrom-Json
$items | Remove-MailboxExtendedProperty -Confirm:$false

For an actual production mailbox, I would prefer separating the operations.

Final Words

One final consideration for this whole process: cleaning up does not remove the cause. If an application generates unique named properties, perhaps unknowingly, Exchange Server may eventually hit the quota again. And since these cmdlets and support scripts exist for Exchange Online, the problem isn’t restricted to on-premises environments. Once you’ve identified a suspicious property family such as X-Application-<unique value>, it may be worth investigating and contacting the vendor, if needed, to prevent current and possible future problems.

The module has also been published on GitHub.

Managed AutoResponder Notifications

A long overdue blog on a solution which was created per request of an Exchange fellow. The original scenario is an organization spinning off, thereby changing their primary e-mail domain. They wanted to inform relations and partners using the old e-mail addresses of this change. However, this solution might also be helpful to organizations after merger and acquisitions or rebranding.

For the sake of the example, let us suppose Fabrikam was acquired by Contoso. Targeted mailboxes are migrated from the Fabrikam tenant to the Contoso tenant. Fabrikam will contain Mail-Enabled Users forwarding messages to their Contoso mailbox counterparts. The migrated mailboxes now hosted in Contoso will be configured to send notifications to senders which sent mail to the old Fabrikam address.

While organizations can resort to 3rd party tools to set up an Exchange Transport Rule with a generic message, a little script might also do the job, offering a more granular and controlled solution.

Solution
The scripted solution is available on GitHub here. It will configure an Inbox rule on the targeted Exchange mailbox(es), which would be the new/migrated mailbox. The rule will trigger when messages land in the inbox which were sent to a specific e-mail address, i.e. the previous e-mail address. It will send out an automatic response, which can consist of a custom subject, message body with an optional embedded image. The configuration of the response is defined in an customizable external XML file:

<?xml version="1.0" encoding="ISO-8859-1"?>  
<config>
  <rule>Contoso Autoresponder</rule>
  <subject>Please update your email recipient to Contoso</subject>
  <body>Dear Sender,

Thank you for your message. Fabrikam is now a whole Contoso subsidiary, and the fabrikam.com e-mail address will change to contoso.com. Your e-mail was forwarded to my new e-mail address. 

Please update contact information, distribution lists, etc. to update [OldMail] e-mail references with my new [Identity] e-mail address. 
 
[logo] 
The Contoso Corporation is a multinational business with its headquarters in Paris.</body>
  <logo>Contoso.png</logo>
</config>

The elements that can be used in the config are:

  • <rule> defines the name of the Inbox rule to be created. When the script runs, it will update any existing previously created inbox rules of the same name.
  • <subject> defines the subject of the response.
  • <body> defines the message body. You can use the following macros here:
    • [OldMail] will get replaced with the original e-mail address.
    • [Identity] will get replaced with the new e-mail address.
    • [Logo] will get replaced with the embedded image.
  • Optionally, <logo> refers to the file name of the image to embed.

Requirements
To run the script, you need the following:

  • Exchange Server 2013 SP1 or later, or Exchange Online.
  • Exchange Web Services (EWS) Managed API 2.21 or later (how to, NuGet package exchange.webservices.managed.api).
  • When using modern authentication or OAuth2, the MSAL library is required (NuGet package Microsoft.Identity.Client). Also, you need to have registered an App in Azure Active Directory with sufficient permissions (e.g. full_access_as_app). After registering the app, Tenant ID, Application ID and certificate or secret is what you need to use with the script to run successfully.
  • In addition to installing the NuGet packages, you can also store their DLLs in the same folder as the script for portability.

Usage
The syntax to run the script is as follows:

.\Set-AutoResponderNotification.ps1 -Identity <Identity> -TemplateFile <File> [-TenantId <TenantId> -ClientId <ClientId> [-CertificateThumbprint <ThumbPrint>] [-CertificateFile <File> -CertificatePassword <SecureString>] [-Secret <SecureString>]] [-Credentials <PSCredential>] [-Clear] [-Overwrite] [-Impersonation] [-TrustAll]

The available parameters and switches are as follows:

  • Identity specifies one or more e-mail addresses of mailboxes to process. Identity supports the pipeline (see examples).
  • OldMail specifies one or more old e-mail addresses to use when configuring the autoresponder message. When specifying multiple identities,
    the number of OldMail entries need to match the number of identities.
  • Server specifies the Exchange Web Services endpoint, for example outlook.office365.com for Exchange Online. When omitted, Autodiscover will be used.
  • Impersonation to use impersonation when accessing the mailbox. When using modern authentication, impersonation is mandatory.
  • TrustAll to accept all certificates including self-signed certificates.
  • TenantId specifies the ID of the Tenant when using a mailbox hosted in Exchange Online.
  • ClientId to specify the Application ID of the registered application in Azure Active Directory.
  • Credentials to specify the Basic Authentication credentials for on-premises usage or against Exchange Online when modern authentication is not an option.
  • CertificateThumbprint is the thumbprint of the certificate to use for modern authentication. The certificate with the public key needs to stored with the registered application for authentication. The certificate with the private key should be present in the local certificate store.
  • CertificateFile and CertificatePassword can be used to specify a certificate file to use. The file should contain the private key; the password protecting the certificate file can be specified using CertificatePassword as a secure string.
  • Secret can be used to specify the secret to authenticate using the registered application. The secret needs to be provided as a secure string.
  • Template
    specifies the XML template file to use when configuring or clearing the autoresponder inbox rule. The format has explained above.
  • Clear specifies if any you want to remove the inbox rules with name specified in the template. Use this when you want to remove autoresponder rules from mailboxes. When using Clear, you don’t need to specify OldMail.
  • Overwrite specifies if any existing inbox rules with name specified in the template should be overwritten. When omitted, the script will skip processing
    mailboxes with inbox rules with conflicting names. Use this when you want to configure the autoresponder only on mailboxes which do not have the rule.

Note that usage of the Verbose, Confirm and WhatIf parameters are supported.

Examples
Nothing more explanatory than an example. When we want to configure the autoresponder on a single mailbox, we can use something like:

image

Here, the autoresponder will get configured on the specified mailbox, triggering when mail has been sent to michel@fabrikam.com using the configuration defined in template.xml. Modern authentication will be used for authentication, using variables for Tenant, Client and in this case secret.

When you want to configure autoresponder for multiple mailboxes, you can for example use a CSV file. It needs to contain two elements which will be passed through pipeline, Identity and OldMail:

Identity,OldMail
philip@contoso.com,p.mortimer@fabrikam.com
francis@contoso.com,f.blake@fabrikam.com

After defining the response in a file template.xml, we can use this CSV to configure inbox rules on the Contoso mailboxes identified by Identity, triggering when mail is sent to their OldMail addresses:

Import-CSV -Path Users.csv | .\Set-AutoResponderNotification.ps1 -Server outlook.office365.com -Impersonation -TemplateFile .\Template.xml -TenantId <TenantId> -ClientId <ClientId> -Overwrite -CertificateThumbprint <Thumbprint>

What will happen is that for every set of Identity and OldMail, the mailbox specified by Identity will be configured with an inbox rule. When an existing rule is found, which is determined using the <rule> element in the XML template, it will get overwritten. The specified certificate will be picked from the local certificate store to authenticate against Tenant with TenantId, as application specified by ClientId.

Note that when the user opens Manage Rules & Alerts in Outlook, the configured inbox rule will be visible. This allows the user to remove it when it is no longer required. After a certain period, administrators can centrally remove these rules as well running the script using the Clear switch.

image

And finally, an example of how this may looks to senders when they receive an autoresponse message, using the sample configuration from the beginning of this article.

image

Application Access Policy
When using the script with modern authentication, you can leverage features such as conditional access to set boundaries for script usage. Also, you can configure application access policies to scope the registered app (script) to a subset of mailboxes. To accomplish this, assign an ApplicationAccessPolicy to the app.

To be more convenient in managing permissions, you can define a distribution group and assign the Application Access Policy with group scope (PolicyScopeGroupId). You then only need to add/remove members as you need to configure mailboxes.

More information about Application Access Policies here. Note that the permissions mentioned to not include full_access_as_app as permission, but it works.

EWS, why not Graph?
Microsoft already announced back in 2018 that development on Exchange Web Services will halt in and focus will shift to Graph. As part of this move, a more recent statement announced deprecation of some least-used API per March 2022, stimulating organizations to switch to using Graph. However, the organization looking for a solution wished for an automatic response with HTML as well as an embedded logo. Because of this, I had to use a template as a reply action.

But where Exchange Web Services supports reply with a template, Graph does not offer this functionality. So, until there is more feature parity between Exchange Web Services and Graph, or EWS goes completely out of service, solutions may still be forced to have a look at EWS for certain tasks.

Exchange 2010-2013 Migration and OAB

Ex2013 LogoLast year, Exchange fellows Andrew Higginbotham, Paul Cunningham as well as the Exchange Team reported on checking, and when necessary configuring, your Offline Address Book (OAB) in your current Exchange Server 2010 environment, prior to installing Exchange Server 2013. Not doing so could result in a complete download of the Offline Address Book created by Exchange Server 2013, titled ‘Default Offline Address List (Ex2013)’.

Today I received a report that there is a different symptom of configuration absence. In this case, the customer reported on the inability to download the offline address book, and upon further inspection the Autodiscover server did not report back on the offline address book URL to use. In other words, OAB information was absent from the Autodiscover response, and Outlook gets confused. Note that this issue was reported in Outlook 2010 after installing Exchange Server 2013 Cumulative Update 10. I’m not sure if this change in behavior was introduced in these later builds of Exchange 2013 or Outlook, but it’s still a good thing to know.

The remedy here of course is to configure any (Exchange 2010) mailbox database with unconfigured Offline Address Book setting, and point them to the default offline address book using:

Get-MailboxDatabase | Where-Object {$_.OfflineAddressBook -eq $Null} | Set-MailboxDatabase -OfflineAddressBook (Get-OfflineAddressBook | Where-Object {$_.IsDefault -eq $True})

Client Message Size Limits

powershell

Last Update: Version 1.4, July 19th, 2019

Exchange Server 2013 and Exchange Server 2016 enforces certain message size limits when it comes to client messages. These limits are in-place so clients can’t generate excessive load on your Exchange environment. These limits are determined for various access methods in multiple web.config files on Exchange Client Access Servers as well as Mailbox Servers.

Sometimes you may have good reasons to increase those limits. For example, when migrating to Office 365 using a product like MigrationWiz, you may want to increase the limit for Exchange Web Service (EWS) requests to allow for migration of larger items. Another example is when you want to allow for bigger attachments in Outlook WebApp (OWA). On TechNet, there’s an article on how to reconfigure these limits. However, the process consists of editing multiple web.config files, replacing multiple values in the same file, and following this process on each Exchange 2013/2016 server in your environment. This is not only labor intensive and prone to error, but becomes tedious when you consider that each Cumulative Update will overwrite your web.config files.

But do not despair. To execute these changes for OWA and EWS, I have created a PowerShell script which will perform these tasks for you.

Requirements
Using the script requires Exchange 2013. You need to provide the server name (default is local server) or AllServers to apply to all Exchange 2013/2016 servers in your environment. The script will modify the web.config remotely using the system share (e.g. C$), using the location of the Exchange installation, and uses IISRESET tool to restart IIS. It will create a backup of the web.config before modifying it.

Notes:

  1. The script checks for running in elevated administrator mode when running against the local machine.
  2. Current version of the script requires Exchange Management Shell, to run Exchange cmdlets for checking installed roles a.o., as the web.config files which require editing depend on the installed roles.
  3. For OWA, add ~33% to the value you want to specify to compensate for encoding overhead.
  4. When connected to an Exchange server, the script processes the server hosting the EMS session last to prevent abortion caused by IIS reset.
  5. Script currently runs against Exchange 2013 or Exchange 2016.

Usage
The script Configure-ClientSizeLimits.ps1 uses the following syntax:

.\Configure-ClientSizeLimits.ps1 [-Server |-AllServers] [-OWA <size>] [-EWS <size>] [-EAS <size>] [-Reset] [-NoBackup] 

A quick walk-through on the parameters and switches:

  • Server specifies the server to configure. When omitted, it will configure the local server. This parameter is mutually exclusive with AllServers.
  • AllServers switch specifies to configure all Exchange 2013 servers. This switch is mutually exclusive with Server.
  • OWA configures the message size limit for Outlook Web Access. Value is in bytes.
  • EWS configures the message size limit for Exchange Web Services. Value is in bytes.
  • EAS configures the message size limit for Exchange ActiveSync. Value is in bytes.
  • NoBackup tells the script not to make backup copies of modified web.config files.
  • Reset switch specifies to perform an IISRESET against servers after reconfiguration of client-specific message size limits.

So, suppose you want to configure OWA, EWS and EAS client message size limits on the local Exchange server, you can use:

.\Configure-ClientSizeLimits.ps1 -OWA 15MB -EWS 15MB EAS 15MB
cs

If you want to configure EWS limits for all servers, resetting IIS, you could use:

.\Configure-ClientSizeLimits.ps1 -AllServers -EWS 10240 -Reset

Download
You can download the script from the TechNet Gallery here or GitHub.

Feedback
Feedback is welcomed through the comments. If you got scripting suggestions or questions, do not hesitate using the contact form.

Revision
See TechNet Gallery page.

Clearing AutoComplete and other Recipient Caches

Exchange 2010 Logo

Last version: 1.21, April 28th, 2021: Updated formatting and link to GitHub

Anyone who has participated in migrations or transitions to Exchange has most likely encountered or has had to work around potential issues caused by the nickname cache. A “cache,” also known by its file extension, NK2 in older Outlook clients, is a convenience feature in Outlook and Outlook WebApp (OWA) which lets users pick recipients from a list of frequently-used recipients. This list is displayed when the end user types in the first few letters.

The potential issue revolves around end users using those lists to send messages, as the list contains cached recipient information. Because this information is static, it may become invalid at some point. Thus, when users pick recipients when sending messages, they may be sending messages to non-existent recipients or invalid e-mail addresses, which create issues like non-delivery of e-mail.

Read the full article over on ENow Solutions Engine blog.

Clean-AutoComplete

Using the script mentioned in the article, which can be used to clear cached recipient information, is straightforward. It requires Exchange 2010 or later and Exchange Web Services Managed API 1.2 (or later) which you can download here. Alternatively, you can copy the Microsoft.Exchange.WebServices.DLL with the script as it will also look for it in the current folder.

The script Clean-AutoComplete.ps1 has the following syntax:

Clear-AutoComplete.ps1 [-Mailbox] <String> [-Server <String>] [-Impersonation] [-Credentials <PSCredential>] [-Type <Array>] [-Pattern <String[]>]

Where:

  • Mailbox is the name or e-mail address of the mailbox.
  • Server is the name of the Client Access Server to access for Exchange Web Services. When omitted, the script will use AutoDiscover.
  • Switch Impersonation specifies if impersonation will be used for mailbox access, otherwise the current user context will be used.
  • Credentials specifies the user credentials to use.
  • Type specifies what cached recipient information to clear. Options are Outlook  (Outlook AutoComplete stream), OWA (OWA Autocomplete stream), SuggestedContacts, RecipientCache or All. Default is Outlook,OWA.
  • Pattern is the pattern of e-mail entries to remove from cache. Only works with OWA, SuggestedContacts and RecipientCache type clearances.

So for example, suppose you want to clear the Autocomplete stream used by Outlook on a mailbox, you can use:

Clear-AutoComplete.ps1 -Identity Olrik -Type Outlook -Verbose
ScreenCap

To remove the Autocomplete stream used by OWA on your Office 365 account, you can use:

Clear-AutoComplete.ps1 -Identity olrik@office365tenant.com –Credentials (Get-Credential) –Type OWA

Be advised that clearing the Outlook AutoComplete stream will only have effect for Outlook running in Online mode. Outlook caches this information as well in the OST file, leaving the options of running Outlook with the /CleanAutocompleteCache switch, or remove and let Outlook recreate the OST file. The temporary Stream_AutoComplete *.dat files created under %USERPROFILE%\AppData\Local\Microsoft\Outlook\RoamCache are used by Outlook to speed things up.

Disabling Auto-Complete and Suggested Contacts
Alternatively, you can disable Auto-Complete, the equivalent of unchecking the Outlook option ‘Use Auto-Complete List to suggest names when typing in the To, Cc and Bcc line‘, by setting the following registry key:

Note: In the examples below, you need to modify the version number in the examples corresponding to the Outlook version you wish to apply these settings against. Use 16.0 as indicated for Outlook 2016, but change it to 15.0 for Outlook 2013, or 14.0 for Outlook 2010.

HKEY_CURRENT_USER\Software\Microsoft\Office\16.0\Outlook\Preferences\
ShowAutoSug=0 (REG_DWORD)

To configure this setting using a Group Policy, use the following registry setting:

HKEY_CURRENT_USER\Software\Policies\Microsoft\office\16.0\Outlook\Preferences\ShowAutoSug=0 (REG_DWORD)

You can also disable Suggested Contacts folder, the equivalent of unchecking the Outlook option ‘Automatically create Outlook contacts for recipients that do not belong to an Outlook Address Book’, with the following registry key:

HKEY_CURRENT_USER\Software\Microsoft\office\16.0\Outlook\Contact\CreateContactsForOneOffs= 0 (REG_DWORD)

The related Group Policy setting is:

HKEY_CURRENT_USER\Software\Policies\Microsoft\office\16.0\Outlook\Contact\CreateContactsForOneOffs= 0 (REG_DWORD)

Feedback
Feedback is welcomed through the comments. If you got scripting suggestions or questions, do not hesitate using the contact form.

Download
You can download the script from GitHub here.