Create a PS script

I am running Exchange 2010

I need to create a Powershell script that will let me get all email from the following domain and save it to a .pst file, can someone help me?
dssinc.com
Apollo SmartAsked:
Who is Participating?
 
Krzysztof KubiakWindows Server AdministratorCommented:
Hi

It's not quite clear what you mean that you want extract all emails from a domain and put it into a pst file?

Do you want to export all emails from all mailboxes into one PST file or do you want to create for each export a seperate PST file?

In general you can achieve exporting mails using the cmdlet:
New-MailboxExportRequest

like this
New-MailboxExportRequest -Mailbox testmailbox -FilePath "\\servername\PSTFileShare\testmailbox.pst"

Before you can use the Mailbox Xport requirst cmdlet you need to assign the account which will run the command proper permission
https://blogs.technet.microsoft.com/nawar/2010/06/24/permissions-to-import-or-export-mailbox-data-in-exchange-2010/


But there is no option where you can say export all emails from all users on a domain to a PST file.

What exactly do you want to achieve?
How large is your Exchange and how many mailboxes do you have?

A example script you can expand and modify would be something like that (I don't have now in front of me Exchange shell so not sure if all cmdlets will be correct):

Export first all mailboxes to a csv file so you cam modify the csv file in case something go missing or something needs to be removed
Get-Mailbox -Server Mailbox01 | export-csv "Csvpath\csvname"

From the CSV copy out the mailboxnames and save into a new csv with the header MailboxName

Use then something like

$CSVFile = import-csv "Location\nameofCSV"

foreach ($Mailbox in $CSVFile){

New-MailboxExportRequest -Mailbox $Mailbox -FilePath "\\servername\PSTFileShare\mailboxname.pst"

}

But before you do such thing like you need to do testing, and you need to review your infrastructure if it does make send to do such thing.
If you Exchange environment is large then I definitely not suggest to do it this way as this can take you days or weeks to finish.
When you run the New-MailboxExportRequest against a lot of mailboxes what exchange only does it creates the Export Request, but it does the Export only in limited numbers (I thing default was 5) the rest will be queued.

If you are looking at Migrating your Exchange environment maybe tools like this will help:
https://www.quest.com/products/migration-manager-for-email-archives/

It's very hard to help you as your question is very generic and we would need to know more what you are trying to achieve.
0
 
Apollo SmartAuthor Commented:
I am trying to export all emails sent and received from a particular domain
the domain is dssinc.com
0
 
AlanConsultantCommented:
Hi Apollo,

Where are the emails currently stored?

Thanks,

Alan.
0
 
Apollo SmartAuthor Commented:
Thank you everyone. I was able to create a script and it worked

Here is the script that worked

$Export = get-mailbox; $Export|%{$_|New-MailboxExportRequest -FilePath "\\wiki\pstHYPERLINK "file://wwn/pst/$($_.alias).pst"\$($_.alias).pst" -ContentFilter {All -like '*@123.com'} }
0
 
AlanConsultantCommented:
Best answer I think.
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.