Jun 16 2021 02:21 AM
Hello all,
I have been struggling for several hours to figure out how to delete all contacts from a shared mailbox in Microsoft 365 using Powershell. To no avail. I can import contacts from a CSV successfully, but any further import just adds the contacts anew. So I need to delete the old ones before importing. And of course I need that automated. I have everything figured out and working except the deletion part.
Remove-MailContact -Identity heregoestheuser ends with an error of “object couldn’t be found”
If anybody has any idea how to do it, I would be eternally grateful.
Jun 16 2021 03:56 AM
Bonjour
avez vous utilisé ce script comme import des contacts csv vers le mailbox ?
Import-ContactList -CSV -CSVData ([System.IO.File]::ReadAllBytes("C:\xxxxx.csv")) -DateCultureName "en-GB" -Identity xxxx@domaine.onmicrosoft.com ?
si oui , c'était quoi la commande lancer pour la supression contact ?
Jun 16 2021 04:03 AM
Hi Kais,
I use similar script:
Import-ContactList -Identity someone@comapany.com -CSV -CSVData ([System.IO.File]::ReadAllBytes("c:\temp\sample.csv"))
That one works correctly.
For deletion I tried
Remove-MailContact -Identity someone@company.com
But it says that "object couldn't be found" for that identity
I'm running it all under global admin account.
Jun 16 2021 04:11 AM
Jun 16 2021 04:14 AM
Jun 16 2021 04:32 AM
Jan 14 2022 07:01 AM - edited Jan 14 2022 07:05 AM
@Kais_mbarki Bonjour, j'aurais aimé savoir si vous aviez eu du changement dans cette question ? J'essaie aussi d'effacer les contacts d'un utilisateur. Je suis capable d'en importer mais pas effacer.
Mise à jour ! J'ai réussi avec
Search-Mailbox -identity USER -SearchQuery kind:contacts -deletecontent
Jan 14 2022 07:29 AM