Remove Some Contact

Irvanda 76 Reputation points
2022-03-30T07:27:29.613+00:00

Hi Everyone,

I want to ask how to remove some contacts on multiple O365 user accounts.

As an admin, I want to remove some contacts in the contact folder of multiple users in my organization with one execution.
Is it possible to use powershell using admin account to do the bulk remove or only each user can remove contacts in their contact folder?

If using powershell is possible, how to do it?

Thank you.

Exchange Server Development
Exchange Server Development
Exchange Server: A family of Microsoft client/server messaging and collaboration software.Development: The process of researching, productizing, and refining new or existing technologies.
540 questions
{count} votes

1 answer

Sort by: Most helpful
  1. Glen Scales 4,436 Reputation points
    2022-03-31T23:14:18.25+00:00

    >As an admin, I want to remove some contacts in the contact folder of multiple users in my organization with one execution.

    You won't be able to do it with one execution with EWS (or the Graph) it needs to be done mailbox by mailbox as that's the context you would be working in

    before you go do the scripting route i would first try a compliance Search https://learn.microsoft.com/en-us/microsoft-365/compliance/search-for-and-delete-messages-in-your-organization?view=o365-worldwide#:~:text=You%20can%20create%20the%20search,Purge%20command%20in%20Step%203.

    Eg using KQL like

    kind:contacts AND EmailAddress:blah@keyman .com

    should limit it to contacts that you can then purge but make sure you test it fully first to ensure you don't delete something unexpected.

    otherwise if you want to start looking at EWS something like https://www.powershellgallery.com/packages/ExchangeContacts/1.2.0.0/Content/functions%5Ccontacts%5CRemove-EXCContact.ps1 may help but will requires the granted of explicit rights or EWS impersonation as being an Admin will have no affect when your working with any of the Mailbox API's

    0 comments No comments

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.