Wednesday, July 03, 2013

Getting data from all mailboxes on exchange 2007

For the second time in 6 months a freedom of information request has been made within the organization I work, this means that yet again I am required to pull a copy of all emails containing the name of the person who made the request.

My setup:
Windows Server 2008 R2 with Exchange 2007 install (all roles on one server).

Where to start:

1) From any email client create a new folder in your email account where you can copy all the emails too (I have used a mailbox called FOIR with a folder called FOI).

2) log onto the server as an administrator and start up "Exchange Powershell".

3) Make sure administrator has good access to all mailboxes:
get-mailboxdatabase | add-adpermission -user administrator -accessrights generic,read, genericWrite
4) Run the search:
get-mailbox | export-mailbox -content keywords "Joe Bloggs" -Targetmailbox FOIR -Targetfolder 'FOI'
Now to extend this a bit:
-content keywords seems to search for each given word seperatly so "boat car plane" will find any email containg boat or car or plane.

Setting in from the first day of this year,
get-mailbox | export-mailbox -content keywords "Joe Bloggs" -Targetmailbox FOIR -Targetfolder 'FOI' -StartDate 01/01/2013
Setting it to exclude certain folders,
get-mailbox | export-mailbox -content keywords "Joe Bloggs" -Targetmailbox FOIR -Targetfolder 'FOI' -excludefolders "\Drafts", "\Junk E-Mail", "\Outbox", "\Journal", "\Calendar", "\Contacts", "\Notes", "\Tasks"

5) Moving all emails found to one folder:
  • Create a folder to move them to (I used FOI_final).
  • In outlook hold ctrl + shift and tap 'f'.
  • Click 'Browse...'.
  • Select the folder you created in step 1 and tick the 'Search subfolders' checkbox, Click 'Ok'.
  • Click 'Find Now'.
  • Click the first message found then hold ctrl and press 'a'.
  • Right click and select 'move' -> 'other folder'
  • Select the newly created final folder then click 'OK'

6) Now the emails are in one folder it is possible to easily export them to a pst file to be handed to who ever needs it.

No comments: