0

We have a list of cell phone contacts which we load from a .pst file to new users when they start using this command:

New-MailboxImportRequest -Mailbox (userid) -FilePath \EX1\c$\ExFiles\CellPhoneContacts.pst -TargetRootFolder "Contacts"

Once finished we log into the users account using OWA, go into "People", expand out "Other Contacts", right click the "Cell Phone List" and hit "Add to Contacts". It then lists a "Cell Phone List" as a subdirectory under their contacts which then through Active Sync adds all the contacts to their phones.

Of course after time the list gets out dated. Is there a command to search a users contacts, in this "Cell Phone List" subfolder, for all contacts with a matching company name (ours) and delete them? I can figure out the looping through users and the re-adding the contacts back in but I can't figure out how to delete whats there. Deleting the entire "Cell Phone List" subfolder would also be acceptable as only our contacts should be in there.

ADY
  • 93
  • 1
  • 12

2 Answers2

0

The main bit you are missing from your question is the version of Exchange, as the different versions give you different options.

However your best option would be to use something like add2exchange from Diditbetter. Keep the information in a central point and have that software keep it up to date. It will be much more efficient than trying to flush the details out.

Sembee
  • 2,884
  • 1
  • 8
  • 11
  • Server is Exchange 2013. And that software, even for the cheapest version, is $900. there should be some type of command to do it, I just can't figure out which. – ADY Apr 11 '17 at 16:17
  • If the functionality existed in Exchange, then the app probably wouldn't exist? Why should there be a command to do it? You are an edge case - the few times this has been suggested in the past the answer has been Add2Exchange because it isn't easily possible. You might be able to get something written to access the mailboxes via EWS, but something built in - it doesn't exist as far as I am aware. – Sembee Apr 11 '17 at 18:04
  • Your logic is backwards. If they are doing it through the app then there exists a command, otherwise how would their app work? – ADY Jul 06 '17 at 14:09
  • The app does the manual work for you. It doesn't use some magic command - it will log in to each mailbox and make the changes. – Sembee Jul 06 '17 at 16:56
  • You said "If the functionality existed in Exchange, then the app probably wouldn't exist?" which is wrong. The functionality has to exist for the app to work in the first place was my point. – ADY Jul 07 '17 at 17:32
0

After a bunch of playing I figured out a workable solution. Turns out if you throw a contact into a normal mail folder the subject line is "Person Name - Company" and that was consistent for all the contacts. So I was able to use the following:

Search-Mailbox -Identity (alias) -SearchQuery 'kind:contacts AND subject:" - Company"' -DeleteContent

(notice company has a space then dash then space first). This deleted out all contacts for the identity with the company name I was searching for.

Now to write a for next loop to first delete out the contacts from everyone's mailboxes then import a fresh list.

ADY
  • 93
  • 1
  • 12