Forum Discussion
Deleting contacts from a 365 shared mailbox
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.
- Kais_mbarkiBrass Contributor
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 ?
- Denis_ChristovCopper Contributor
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.
- Kais_mbarkiBrass Contributordans la commande import : vous avez utilisé -Identity UserpricipaleName ?