Powershell in Ex2007 help needed to find all emails to and from a particular domain.
Hi Everyone, Am at my wits' end here. I need to query a SBS 2008 / Exchange 2007 server for all emails sent to and from 'abc.com' domain and copy all the emails it finds to a pst folder. This is for a compliance issue, we have been asked to produce all emails sent between our users and another company. I have been running the following command: get-mailbox -server servername | export-mailbox -recipientkeywords abc.com -pstfolderpath C:\temp This produces a load of PST files, some of which are quite large. But the emails in there are not exclusively to and from abc.com. Sometimes the domain isn't involved at all. Some pst files are almost 400MB large but when I open them in Outlook there are no emails inside! Am i running the wrong command? I tried another variant which was this: Get-Mailbox -ResultSize Unlimited -Filter { EmailAddresses -like "*@abc.com " } | export-mailbox -pstfolderpath C:\temp but it produced either an error, or just brought me back to the command prompt! Any advice from someone familiar with this? Google has proved unhelpful for once! Thanks in advance.
March 8th, 2010 12:35am

Am i running the wrong command? I tried another variant which was this: Get-Mailbox -ResultSize Unlimited -Filter { EmailAddresses -like "*@abc.com " } | export-mailbox -pstfolderpath C:\temp but it produced either an error, or just brought me back to the command prompt! Any advice from someone familiar with this? Google has proved unhelpful for once! Thanks in advance. What error are u getting with this piece of script. Try this with foreach like this: Get-Mailbox -ResultSize Unlimited -Filter { EmailAddresses -like "*@abc.com " } | foreach{ export-mailbox $_.Identity -pstfolderpath C:\temp} Regards,Laeeq Qazi|Team Lead(Exchange + Sharepoint + BES + DynamicsCRM) www.HostingController.com
Free Windows Admin Tool Kit Click here and download it now
March 8th, 2010 1:14am

Get-Mailbox -Server servername | Export-Mailbox -TargetMailbox ExportMailbox -TargetFolder Recipients - RecipientKeywords @abc.com –MaxThreads 10 should workFull time IT consultant since 1998 mainly on Exchange\ISA\AD MCSE NT4.0,2000/2003, CCNA MCITP: Enterprise Messaging Administrator 2007/2010 MCT since 2001
March 8th, 2010 1:45am

You might want to check this out:http://blogs.technet.com/richardroddy/archive/2009/11/18/export-mailbox-using-a-filter-does-not-export-anything.aspx
Free Windows Admin Tool Kit Click here and download it now
March 8th, 2010 1:48am

hi, thanks for your help but when I run that command it just takes me back to the command prompt and doesn't appear to do anything at all.
March 8th, 2010 1:54am

can you try the following Get-Mailbox -Server servername | Export-Mailbox -TargetMailbox ExportMailbox -TargetFolder Recipients - RecipientKeywords @abc.com –MaxThreads 10 you will of course need to create a mailbox called targetmailbox Full time IT consultant since 1998 mainly on Exchange\ISA\AD MCSE NT4.0,2000/2003, CCNA MCITP: Enterprise Messaging Administrator 2007/2010 MCT since 2001
Free Windows Admin Tool Kit Click here and download it now
March 8th, 2010 2:00am

Sure I will try this now, but I just have a couple of questions. 1) what does the maxthreads switch do? 2) will it automatically create the subfolder -targetfolder? Thanks
March 8th, 2010 2:16am

Also, would I have to run this again with a -senderkeywords switch to get received items as well? I assume they would merge into the same folder if so?
Free Windows Admin Tool Kit Click here and download it now
March 8th, 2010 2:21am

can you try the following Get-Mailbox -Server servername | Export-Mailbox -TargetMailbox ExportMailbox -TargetFolder Recipients - RecipientKeywords @abc.com –MaxThreads 10 you will of course need to create a mailbox called targetmailbox Full time IT consultant since 1998 mainly on Exchange\ISA\AD MCSE NT4.0,2000/2003, CCNA MCITP: Enterprise Messaging Administrator 2007/2010 MCT since 2001 I get an error - cannot expand splatted variable abc.com; they cannot be part of expression or array. Any ideas?
March 8th, 2010 3:10am

Never seen this ! 1) MaxThread defines how many mailboxes will be processed at a time the default is 4 (I believe) 2) Did you create the ExportMailbox user and gave it a mailbox ? 3) can you try to enclose @abc.com with double quotes ? 4) Can you share a screenshot of the command/errorFull time IT consultant since 1998 mainly on Exchange\ISA\AD MCSE NT4.0,2000/2003, CCNA MCITP: Enterprise Messaging Administrator 2007/2010 MCT since 2001
Free Windows Admin Tool Kit Click here and download it now
March 8th, 2010 9:11am

Hi, I didn't bother to create the export mailbox user i just sent it to the administrator's mailbox. I haven't tried with double quotes but will do so now and report back with a screenshot if there is an error. THanks.
March 8th, 2010 2:02pm

Ok - it is now running having put the domain in 'quotes'. Next question - I'm confused slighlty by the 'recipientkeywords' switch. Will that export all emails sent to and from each mailbox? Surely the domain in question will either be the recipient or the sender so I will only get mail sent and not received? Please could you let me know if this is the case, and if so, how I should get the emails that are received by the users also? Thanks very much.
Free Windows Admin Tool Kit Click here and download it now
March 8th, 2010 10:36pm

Ok, this is clearly not working. It is just exporting all emails and dumping them into a folder - it doesn't appear to be filtering them at all? This is the command I'm running: Get-Mailbox -Server servername | Export-Mailbox -TargetMailbox administrator -TargetFolder targetfolder -RecipientKeywords "*@abc.com" –MaxThreads 10 Any ideas? Thanks!
March 8th, 2010 11:28pm

I am confident the syntax is correct, can you try rebuilding the full index of your database http://technet.microsoft.com/en-us/library/aa995966%28EXCHG.80%29.aspx as per http://blogs.technet.com/richardroddy/archive/2009/11/18/export-mailbox-using-a-filter-does-not-export-anything.aspx Full time IT consultant since 1998 mainly on Exchange\ISA\AD MCSE NT4.0,2000/2003, CCNA MCITP: Enterprise Messaging Administrator 2007/2010 MCT since 2001
Free Windows Admin Tool Kit Click here and download it now
March 9th, 2010 2:49am

Ok thanks; I'm trying that now. I'm at the stage where I have found the folder where the indexes are; but the article isn't very helpful after that. Do I just delete the index.000 files etc? M
March 9th, 2010 3:27am

This topic is archived. No further replies will be accepted.

Other recent topics Other recent topics