Link to home
Start Free TrialLog in
Avatar of street9009
street9009Flag for United States of America

asked on

Powershell - Delete Contacts from "Contacts" folder only

I'm working with an Exchange 2016 server (on-prem) and I'd like to run a PowerShell command to remove contacts from a user's mailbox, but only from the "Contacts" folder. If the user has any custom folders, I would not want to touch those.

search-mailbox -identity USERNAME -searchquery kind:contacts -deletecontent

Open in new window


This command works, but it deletes all contacts from all folders. Is there a way to restrict this command (or another like it) to only the default "Contacts" folder?
Avatar of Ajay Chanana
Ajay Chanana
Flag of India image

Search-Mailbox -TargetFolder <String>


add target folder in the above query should work for you.
ASKER CERTIFIED SOLUTION
Avatar of timgreen7077
timgreen7077

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of street9009

ASKER

OWA and/or Outlook won't work as I need to be able to do this en-masse. Is there any kind of tool at all that can do this or am I out of luck?
Avatar of timgreen7077
timgreen7077

I would never say there is no 3rd party tool for that, but not one that i know of.