Exchange
--
Questions
--
Followers
Top Experts
I want to export all messages sent to and from certain email addresses to a pst. I dont want to delete any messages from mailboxes just export them to a pst.
I found a similar post here https://www.experts-exchange.com/questions/27898646/Exchange-2007-export-all-messages-from-one-specific-sender.html but the command wont work for 2010 sp3 (sbs2011)
So advice please, as they could be required for a legal case
Thanks
Zero AI Policy
We believe in human intelligence. Our moderation policy strictly prohibits the use of LLM content in our Q&A threads.
Get-Mailbox -ResultSize Unlimited | New-MailboxExportRequest -ContentFilter {(sender -eq "smtp@domain.com")} -FilePath "\\SERVER\PSTFiles\ExportMessages.PST"
I have not been able to test this but it should do the trick. Just change the smtp address in the script with the sender you are looking for.
Will.
In short i think what has happened is i needed a new pst for each user it found the email address in.
The pst it created was only 800kb big and only included folders, no emails, so maybe it copied all the folders from the first user in the queue that it found the email address in, but no emails ????
Name Mailbox Status
---- ------- ------
MailboxExport domain.local/MyBusiness/Us
MailboxExport domain.local/MyBusiness/Us
MailboxExport domain.local/MyBusiness/Us
MailboxExport domain.local/MyBusiness/Us
The server or share name specified in the path may be invalid, or the file could be locked.
+ CategoryInfo : NotSpecified: (9:Int32) [New-MailboxExportRequest]
+ FullyQualifiedErrorId : 1D53B743,Microsoft.Exchang
The server or share name specified in the path may be invalid, or the file could be locked.
+ CategoryInfo : NotSpecified: (10:Int32) [New-MailboxExportRequest]
+ FullyQualifiedErrorId : 1D53B743,Microsoft.Exchang






EARN REWARDS FOR ASKING, ANSWERING, AND MORE.
Earn free swag for participating on the platform.
new-ManagementRoleAssignme
$Mailbox = Get-Mailbox -ResultSize Unlimited
Foreach ($user in $Mailbox) {
New-MailboxExportRequest -Identity $user -ContentFilter {(sender -eq "smtp@domain.com")} -FilePath "\\SERVER\PSTFiles\$user.pst
}
Will.
As for the second script is that to be run directly in EMS?

Get a FREE t-shirt when you ask your first question.
We believe in human intelligence. Our moderation policy strictly prohibits the use of LLM content in our Q&A threads.
add-pssnapin microsoft.exchange.managem
Will.
Unexpected token 'in' in expression or statement.
At line:1 char:63
+ $Mailbox = Get-Mailbox -ResultSize Unlimited Foreach ($user in <<<< $Mailbox) {New-MailboxExportRequest -Identity $u
ser -ContentFilter {(sender -eq "dd@mydomain.com")} -FilePath "\\WSDC01\export\$user.PST
+ CategoryInfo : ParserError: (in:String) [], ParentContainsErrorRecordE
+ FullyQualifiedErrorId : UnexpectedToken






EARN REWARDS FOR ASKING, ANSWERING, AND MORE.
Earn free swag for participating on the platform.
Type $mailbox (press enter) see if you get all of the mailboxes are results.
If $mailbox gives you all of the mailbox results then run the rest of the command.
foreach ($user in $mailbox) { .........
The above error message you are getting appears that it does not like the variable.
Will.
and the following message came up for each user
A positional parameter cannot be found that accepts argument 'Discovery Search Mailbox'.
+ CategoryInfo : InvalidArgument: (:) [New-MailboxExportRequest]
+ FullyQualifiedErrorId : PositionalParameterNotFoun
Will.

Get a FREE t-shirt when you ask your first question.
We believe in human intelligence. Our moderation policy strictly prohibits the use of LLM content in our Q&A threads.
new-ManagementRoleAssignme
Or should i run it exactly as you wrote
new-ManagementRoleAssignme
I will test the script above in my lab. I have not tested this.
Will.
$Mailbox = Get-Mailbox -ResultSize Unlimited
Foreach ($user in $Mailbox) {
New-MailboxExportRequest -Mailbox $user -ContentFilter {(sender -eq "smtp@domain.com")} -FilePath "\\SERVER\ShareName\$user.pst
}
That should do it. Will.






EARN REWARDS FOR ASKING, ANSWERING, AND MORE.
Earn free swag for participating on the platform.
Partial success. I have to run it line by line, it created a new pst for each user, it also exported all the users folders. But it didnt export any emails in any of the folders. Any ideas?
As for the export It has to export all of the individual mailboxes regardless if it finds anything. It creates the entire mail structure and then from there will place any of the mail items in the folders where it found them in the source mailbox.
Will.
when i run the script i get the following
[PS] D:\>export.ps1
The term 'export.ps1' is not recognized as the name of a cmdlet, function, script file, or operable program. Check the
spelling of the name, or if a path was included, verify that the path is correct and try again.
At line:1 char:11
+ export.ps1 <<<<
+ CategoryInfo : ObjectNotFound: (export.ps1:String) [], CommandNotFoundException
+ FullyQualifiedErrorId : CommandNotFoundException

Get a FREE t-shirt when you ask your first question.
We believe in human intelligence. Our moderation policy strictly prohibits the use of LLM content in our Q&A threads.
When you go to the directory where the script is located you need to run the script using .\export.ps1.
Will.
The script ran but again the exported users only had folders and no emails exported, any ideas?






EARN REWARDS FOR ASKING, ANSWERING, AND MORE.
Earn free swag for participating on the platform.
Will.

Get a FREE t-shirt when you ask your first question.
We believe in human intelligence. Our moderation policy strictly prohibits the use of LLM content in our Q&A threads.
Will.
Thanks
David






EARN REWARDS FOR ASKING, ANSWERING, AND MORE.
Earn free swag for participating on the platform.
Exchange
--
Questions
--
Followers
Top Experts
Exchange is the server side of a collaborative application product that is part of the Microsoft Server infrastructure. Exchange's major features include email, calendaring, contacts and tasks, support for mobile and web-based access to information, and support for data storage.