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
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.
Thanks for the good info! Nice to know there are ways to manage the AutoComplete using PowerShell.
LikeLike
Pingback: Weekly IT Newsletter – July 14-18, 2014 | Just a Lync Guy
Pingback: NeWay Technologies – Weekly Newsletter #104 – July 17, 2014 | NeWay
Pingback: NeWay Technologies – Weekly Newsletter #104 – July 18, 2014 | NeWay
I’m receiving the following error message. Any suggestions?
PS C:\Office365\PowerShell> .\Clear-AutoComplete.ps1 -mailbox xxx@domain -Server outlook.office365.com -type All -Verbose
VERBOSE: Loading C:\Program Files\Microsoft\Exchange\Web Services\2.0\\Microsoft.Exchange.WebServices.dll
VERBOSE: Loaded Microsoft.Exchange.WebServices v15.0.0.0
Processing mailbox xxx@domain
VERBOSE: Set to trust all certificates
VERBOSE: Using Exchange Web Services URL https://outlook.office365.com/EWS/Exchange.asmx
C:\Office365\PowerShell\Clear-AutoComplete.ps1 : Can’t access mailbox information store
At line:1 char:1
+ .\Clear-AutoComplete.ps1 -mailbox xxx@domain -Server outlook.office3 …
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : NotSpecified: (:) [Write-Error], WriteErrorException
+ FullyQualifiedErrorId : Microsoft.PowerShell.Commands.WriteErrorException,Clear-AutoComplete.ps1
Also tried the following:
PS C:\Office365\PowerShell> .\Clear-AutoComplete.ps1 -mailbox xxx@domain -type All -Verbose
VERBOSE: Loading C:\Program Files\Microsoft\Exchange\Web Services\2.0\\Microsoft.Exchange.WebServices.dll
VERBOSE: Loaded Microsoft.Exchange.WebServices v15.0.0.0
Processing mailbox xxx@domain
VERBOSE: Set to trust all certificates
VERBOSE: Looking up EWS URL using Autodiscover for xxx@domain
C:\Office365\PowerShell\Clear-AutoComplete.ps1 : A positional parameter cannot be found that accepts argument ‘Exception calling “AutodiscoverUrl” with “2” argument(s): “The Autodiscover service couldn’t be located.”‘.
At line:1 char:1
+ .\Clear-AutoComplete.ps1 -mailbox xxx@domain -type All -Verbose
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : InvalidArgument: (:) [Clear-AutoComplete.ps1], ParameterBindingException
+ FullyQualifiedErrorId : PositionalParameterNotFound,Clear-AutoComplete.ps1
LikeLike
1) “Can’t access mailbox information store”.
Seems like permission issue, see https://eightwone.com/2014/08/13/application-impersonation-to-be-or-pretend-to-be/
2) “The Autodiscover service couldn’t be located”
The Autodiscover service is not configured for @domain or there is a problem accessing it or a problem with Autodiscover.
Are you running this for an Office 365 mailbox? Are you running this for on-prem for an on-prem mailbox?
LikeLike
I get a similar “AutodiscoverUrl” error.
VERBOSE: Loading C:\Program Files\Microsoft\Exchange\Web Services\2.2\\Microsoft.Exchange.WebServices.dll
VERBOSE: Loaded Microsoft.Exchange.WebServices v15.0.0.0
Processing mailbox user123@xyz.onmicrosoft.com (user123@xyz.onmicrosoft.com)
VERBOSE: Set to trust all certificates
VERBOSE: Using credentials user123
VERBOSE: Looking up EWS URL using Autodiscover for user123@xyz.onmicrosoft.com
C:\Users\user123\Clear-AutoComplete.ps1 : A positional parameter cannot be found that accepts argument ‘Exception
calling “AutodiscoverUrl” with “2” argument(s): “The Autodiscover service couldn’t be located.”‘.
At line:1 char:1
+ .\clear-autocomplete.ps1 -Mailbox user123@xyz.onmicrosoft.com …
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : InvalidArgument: (:) [Clear-AutoComplete.ps1], ParameterBindingException
+ FullyQualifiedErrorId : PositionalParameterNotFound,Clear-AutoComplete.ps1
What is the Autodiscover service, and do I “need” it for this script/process to run/work?
Thanks,
Dave
LikeLike
Since Exchange 2007, Autodiscover not only provides configuration information to clients but also is used to discover and resolve endpoint information for availability information for example. More information: http://blogs.technet.com/b/rmilne/archive/2011/10/21/exchange-amp-the-autodiscover-web-service.aspx
You can override the scripts attempt to use autodiscover to determine the endpoint to talk to by specifying -Server parameter with FQDN of your Exchange server.
LikeLike
Thanks… but how to I determine my “Exchange server”? We’re using OWA via https://outlook.office365.com/owa… and not using any clients.
LikeLike
Hi Michael,
Script runs successfully, OWA autocomplete cache is cleared immediately but cache is still preserved in Outlook.
Do you have any suggestions what may be the cause?
Regards,
Marko
LikeLike
You must close Outlook to close the cache.
Outlook just write the cleared cache when you exit Outlook
LikeLike
Hi Michel,
I’m working on a Exchange2013 On-Premise installation and got your script run with a few changes:
– line 240: $Folder.Empty() needs two parameters. Second one could be $true/$false for the recursive folder deletion. It’s mandatory
– line 260: $RecipientCacheFolder.Empty() needs two parameters. Second one could be $true/$false for the recursive folder deletion. It’s mandatory
– line 287: [Microsoft.Exchange.WebServices.Data.ExchangeVersion] changed from “Exchange2010_SP1” to “Exchange2013”
I also had to run the following cmdlet to let the impersonation work as expected:
New-ManagementRoleAssignment –Name:impersonationAssignmentName Role:ApplicationImpersonation –User:()
Regards,
Simone
LikeLike
Thanks for the feedback. Note that you can use Exchange2010 ‘mode’ to communicate against Exchange 2013+, it’s only to unlock Exchange2013+ specific operations (and syntax as you found out 🙂 ).
LikeLike
Pingback: Something More about Autocomplete | nehrunotes
Hi, I get the following error:
C:\Scripts\Migration\LMH\Clear-AutoComplete.ps1 : Can’t access mailbox information store
At line:1 char:25
+ .\Clear-AutoComplete.ps1 <<<< -Mailbox tabcd -Credentials $cred -Type All -Verbose -Server owa.ynhh.org
+ CategoryInfo : NotSpecified: (:) [Write-Error], WriteErrorException
+ FullyQualifiedErrorId : Microsoft.PowerShell.Commands.WriteErrorException,Clear-AutoComplete.ps1
I'm using an account that has full access to all mailboxes. Should I use the Impersonation option instead?
LikeLike
Here is the verbose information:
[PS] C:\Scripts\Migration\LMH>.\Clear-AutoComplete.ps1 -Mailbox tabcd -Credentials $cred -Type All -Verbose -Server NLBNAME
VERBOSE: Loading C:\Scripts\Migration\LMH\Microsoft.Exchange.WebServices.dll
VERBOSE: Loaded Microsoft.Exchange.WebServices v14.0.0.0
Processing mailbox tabcd (Test.ABCD@domain.com)
VERBOSE: Set to trust all certificates
VERBOSE: Using credentials account info
VERBOSE: Using Exchange Web Services URL https://NLBNAME/EWS/Exchange.asmx
C:\Scripts\Migration\LMH\Clear-AutoComplete.ps1 : Can’t access mailbox information store
At line:1 char:25
+ .\Clear-AutoComplete.ps1 <<<< -Mailbox tabcd -Credentials $cred -Type All -Verbose -Server owa.ynhh.org
+ CategoryInfo : NotSpecified: (:) [Write-Error], WriteErrorException
+ FullyQualifiedErrorId : Microsoft.PowerShell.Commands.WriteErrorException,Clear-AutoComplete.ps1
LikeLike
Does the account have proper full permissions configured, and you took into account a period to wait for FMA to become effective?
Configure impersonation and try that route; if that works, there was perhaps something wrong with (in-mailbox) permissions.
If it doesn’t, is there perhaps a firewall blocking port 443 traffic on that port?
LikeLike
Hi Michael, Thanks for the quick response. This is on-prem, so the firewall blocking should not come into play, correct?
I just tired again and if failed again.
My account does have impersonation rights:
MAImpersonationAssignmentNa… ApplicationImpersonation Boluk, Sahin User Direct Boluk, Sahin
LikeLike
Also, I’m running the command from the CAS server directly, not sure if that matters at all.
LikeLike
Shouldn’t matter, but you should run it from a PowerShell prompt, not the Exchange Management Shell.
LikeLike
Thanks again, tried in PowerShell prompt as administrator, and it still fails at the same place…..
LikeLike
Hi Michael,
I figured out how to run the script. I was using domain\ID, and I tried UserID@domain and that works now.
Only thing is, it runs but doesn’t clear the cache. I tested with a test account, and below is the output, says no item found, but there is on the mailbox, any thoughts?
VERBOSE: Loading C:\Scripts\Migration\LMH\Microsoft.Exchange.WebServices.dll
VERBOSE: Loading module from path ‘C:\Scripts\Migration\LMH\Microsoft.Exchange.WebServices.dll’.
VERBOSE: Loaded Microsoft.Exchange.WebServices v14.0.0.0
Processing mailbox xxxxxx
VERBOSE: Set to trust all certificates
VERBOSE: Using credentials xxxxxx
VERBOSE: Using Exchange Web Services URL https://xxxxxx/EWS/Exchange.asmx
VERBOSE: No AutoComplete Stream item found.
VERBOSE: No OWA AutoComplete item found.
VERBOSE: No ‘Suggested Contacts’ folder found.
VERBOSE: No RecipientCache folder found.
LikeLike
Hi Michel,
I’m having a similar issue that Sahin has. The script is running well and with not errors but is not finding any autocomplete cache on the mailbox we’ve tested. Logging in to the mailbox still shows the Autocomplete entries.
Thanks,
Neil
LikeLike
The client also cached the AutoComplete entry. You’re using Online mode or Cached Mode?
LikeLike
Hello Michel! Thank you for the article and the script, greatly appreciate it. Recently we had someone setup a user incorrectly, which we then had to re-create with the proper name. After which, some of our users can email correctly, but others cannot email. We seem to get a NDR, mainly when using the Auto-Complete. I stumbled across your article and figured I’d give it a try but when running I am seeing the following:
New-Object : Multiple ambiguous overloads found for “ExchangeService” and the argument count: “1”.
At C:\temp\Clear-AutoComplete.ps1:291 char:22
+ $EwsService= New-Object Microsoft.Exchange.WebServices.Data.ExchangeServ …
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : InvalidOperation: (:) [New-Object], MethodException
+ FullyQualifiedErrorId : ConstructorInvokedThrowException,Microsoft.PowerShell.Commands.NewObjectCommand
The property ‘UseDefaultCredentials’ cannot be found on this object. Verify that the property exists and can be set.
At C:\temp\Clear-AutoComplete.ps1:292 char:9
+ $EwsService.UseDefaultCredentials= $true
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : InvalidOperation: (:) [], RuntimeException
+ FullyQualifiedErrorId : PropertyNotFound
The property ‘UseDefaultCredentials’ cannot be found on this object. Verify that the property exists and can be set.
At C:\temp\Clear-AutoComplete.ps1:305 char:13
+ $EwsService.UseDefaultCredentials= $true
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : InvalidOperation: (:) [], RuntimeException
+ FullyQualifiedErrorId : PropertyNotFound
VERBOSE: Looking up EWS URL using Autodiscover for {MAILBOX NAME}
C:\temp\Clear-AutoComplete.ps1 : Autodiscover failed: You cannot call a method on a null-valued expression.
At line:1 char:1
+ .\Clear-AutoComplete.ps1 -Mailbox {MAILBOX NAME} -Type Outlook -Verbose
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : NotSpecified: (:) [Write-Error], WriteErrorException
+ FullyQualifiedErrorId : Microsoft.PowerShell.Commands.WriteErrorException,Clear-AutoComplete.ps1
Any thoughts as to what would be causing this? I am running the Exchange Management PS as a domain admin account, on the Exchange server and have ensured the API is installed as well.
Thanks in advance,
Kyle
LikeLike
Try running the script from a regular PowerShell session, i.e. not from EMS
LikeLike
Well, the issue cleared up with using Auto-Complete, somehow. But now the user can only be found when using Advanced Search, not in the normal GAL. I tell ya, if it’s not one thing it’s another!!
Thanks Michel!
LikeLike
Can take a while for any updates to the GAL to drizzle down to clients. Here’s an article explaining the process
http://techgenix.com/offline-address-book-changes-exchange-2013/
LikeLike
Great information Michel, thanks so much for that!! And it does appear that things are now showing up in the GAL as they should!
LikeLike
Hi.
I am a complete newbie for Powershell but the auto suggestion have annoying me off and I decided to see if I could run your script.
I get the following message when running it in powershell (With admin)
PS C:\test> .\Clear-AutoComplete.ps1 -mailbox thomas@XXX.XX -Server outlook.office365.com -type All -Verbose
C:\test\Clear-AutoComplete.ps1 : A parameter cannot be found that matches parameter name ‘mailbox’.
At line:1 char:26
+ .\Clear-AutoComplete.ps1 -mailbox thomas@t-and.dk -Server outlook.off …
+ ~~~~~~~~
+ CategoryInfo : InvalidArgument: (:) [Clear-AutoComplete.ps1], ParameterBindingException
+ FullyQualifiedErrorId : NamedParameterNotFound,Clear-AutoComplete.ps1
What am I doing wrong ?
LikeLike
Found out after playing around that i needed to logon to the server. 🙂
Now i get this error
PS C:\test> .\Clear-AutoComplete.ps1 -Identity thomas@XXX -Server outlook.office365.com -Credentials $Credentials -Type all -Verbose
VERBOSE: Loading C:\test\Microsoft.Exchange.WebServices.dll
VERBOSE: Loaded Microsoft.Exchange.WebServices v15.0.0.0
Processing mailbox thomas@t-and.dk (thomas@t-and.dk)
VERBOSE: Set to trust all certificates
VERBOSE: Using Exchange Web Services URL https://outlook.office365.com/EWS/Exchange.asmx
C:\test\Clear-AutoComplete.ps1 : Can’t access mailbox information store
At line:1 char:1
+ .\Clear-AutoComplete.ps1 -Identity thomas@XXX -Server outlook.of …
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : NotSpecified: (:) [Write-Error], WriteErrorException
+ FullyQualifiedErrorId : Microsoft.PowerShell.Commands.WriteErrorException,Clear-AutoComplete.ps1
LikeLike
the challenge is i seem to have full access rights
Thomas EURPR05A001\Thoma… {FullAccess} False False
Any help on why i get this message ?
LikeLike
Given perms are in place, is basic auth allowed and EWS not blocked?
LikeLike
It worked, but no idea what i did 🙂
cmdlet Get-Credential at command pipeline position 1
Supply values for the following parameters:
Credential
VERBOSE: Loading C:\test\Microsoft.Exchange.WebServices.dll
VERBOSE: Loaded Microsoft.Exchange.WebServices v15.0.0.0
Processing mailbox thomas@t-and.dk (thomas@t-and.dk)
VERBOSE: Set to trust all certificates
VERBOSE: Using credentials Thomas@t-and.dk
VERBOSE: Using Exchange Web Services URL https://outlook.office365.com/EWS/Exchange.asmx
VERBOSE: No Suggested Contacts folder found.
VERBOSE: No RecipientCache folder found.
LikeLike
The mails under suggestions are still showing up
LikeLike
You had Outlook closed when performing the operation?
LikeLike
And i have changed outlook to online mode no change.
LikeLike
The parameter name is Identity, not Mailbox
LikeLike
Hello Thanks for the script
Is possible delete only one email address? not all of autocomplete list.
Thanks
LikeLike
In the current version, no. Noted for future ideas.
LikeLike
Thanks
LikeLike
Hi Michel,
Thank you for writing the script.
I was able to clear run the script and able to clear the Outlook Autocomplete.
However, get message “No OWA AutoComplete item found” for OWA.
Please share your thoughts.
LikeLike
My thoughts on what? The item used to store OWA name cache was found to be absent.
LikeLike
So, can’t find the user to whom the script is directed?
Also during the execution of the script sometimes I get an error.
.\Clear-AutoComplete.ps1 -Identity username@tenant.com -Credentials (Get-Credential) -Type OWA
Processing mailbox username@tenant.com
Write-Verbose : A parameter cannot be found that matches parameter name “f”.
C:\ps_test\Clear-AutoComplete.ps1:464 char:50
+ Write-Verbose ‘Using EWS on CAS {0}’ -f $EwsService.Url
+ ~~
+ CategoryInfo : InvalidArgument: (:) [Write-Verbose], ParameterBindingException
+ FullyQualifiedErrorId : NamedParameterNotFound,Microsoft.PowerShell.Commands.WriteVerboseCommand
Processing OWA AutoComplete for username@tenant.com
No OWA AutoComplete item found
LikeLike
You run this from a regular PowerShell session, i.e. not Exchange Management Shell?
LikeLike
Yes, I run it from regular PowerShell. Microsoft recommends it for administering Exchange Online.
LikeLike
Hey Michel,
when i am running the script in verbose mode, I can the following output:
AUSFÜHRLICH: Loading C:\Program Files\Microsoft\Exchange\Web Services\2.2\\Microsoft.Exchange.WebServices.dll
AUSFÜHRLICH: Loaded Microsoft.Exchange.WebServices v15.0.0.0
Processing mailbox HIDDEN (HIDDEN)
AUSFÜHRLICH: Set to trust all certificates
AUSFÜHRLICH: Using credentials gh-adressbuch@die-frischemacher.de
AUSFÜHRLICH: Looking up EWS URL using Autodiscover for HIDDEN
AUSFÜHRLICH: Using EWS on CAS https://outlook.office365.com/EWS/Exchange.asmx
AUSFÜHRLICH: No AutoComplete Stream item found.
AUSFÜHRLICH: No OWA AutoComplete item found.
AUSFÜHRLICH: No Suggested Contacts folder found.
AUSFÜHRLICH: No RecipientCache folder found.
Can you explain me what no folder found means?!?
Could the mailbox language (is german) be the reason or are the folders already empty?!?
Thanks for advice!!!
Denis
LikeLike
There is no ‘Well Known Folder’ equivalent for Suggested Contacts, so yes it’s picked based on the name ‘Suggested Contacts’. If the name in German locale is different, it won’t be found and therefor also not cleared.
LikeLike
Hi! Since Technet is down, where can we find the powershell script now?
LikeLike
GitHub, at https://github.com/michelderooij/Clear-AutoComplete
LikeLike
Has anyone had success disabling the autocomplete feature via Intune instead of GPO?
HKEY_CURRENT_USER\Software\Microsoft\Office\16.0\Outlook\Preferences\
ShowAutoSug=0 (REG_DWORD)
^^Doesn’t seem to work consistently
While the below fails when scripted due to the permissions on the policies keys
HKEY_CURRENT_USER\Software\Policies\Microsoft\office\16.0\Outlook\Preferences\ShowAutoSug=0 (REG_DWORD)
LikeLike
Hello,
great script, good work, it worked for me. A question, is it possible to delete only one entry in the Automcomplete Stream?
Best Regards,
Florian
LikeLike
In theory, yes (the Autocomplete stream is an XML) but currently script does not support this.
LikeLike
Ah okay,
i found this snippet from here:
https://community.spiceworks.com/topic/1836616-removing-single-outlook-autocomplete-entry-from-all-users
##### Convert the byte array and store as xmldoc. There seems to be a special character at the beginning so I don’t include it in the xml
$stringData = [System.Text.Encoding]::UTF8.GetString($config.XmlData).Substring(1)
$xmlDoc.LoadXml($stringData)
$nodes = $xmlDoc.SelectNodes(“/AutoCompleteCache/entry”)
write-host “converting array”
#loop through each entry and remove if necessary
foreach($node in $nodes)
{
if($node.smtpAddr -ne $null -and $node.smtpAddr -eq $badDomain)
{
$node.ParentNode.RemoveChild($node) | Out-Null
write-host “`tRemoving: $($node.smtpAddr) from $($mailbox.PrimarySMTPAddress)”
}
else {write-host “`tNot Found $($node.smtpAddr) from $($mailbox.PrimarySMTPAddress)”}
}
Is it possible to put in this in your script?
Best regards,
Florian
LikeLike
Hello,
is it possible with this little snippet?
Best regards,
Florian
LikeLike
It contains the logic required.
LikeLike
Hello,
i don’t understand, sorry, what do you mean with that?
Best Regards,
Florian
LikeLike
Only just noticed your snippet refers to the OWA autocomplete data. The OWA autocomplete is in text; function to selectively clear items is already included (pattern parameter). The Outlook (for desktop) is a binary data, and cannot be manipulated as easily. I’ll make a note to have another look, but usually it is not worth othering and just clear the entry. Meanwhile, I’m including parameters for OAuth in addition to Basic Authentication.
LikeLike
doesnt work. i keep getting NOT AUTHORIZED while i pass admin icredentials and target the admin mailbox….
LikeLike
That might happen if you use an authentication method not approved (blocked) by Exchange Online, e.g. requiring OAuth and using Basic Authentication (Security Defaults, Authentication Policy) or Conditional Access is at play. Consult the Azure AD Sign-In logs to look for clues.
LikeLike