Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win


Exchange powershell mass exporting to PST

Posted on 2016-08-16
Medium Priority
1 Endorsement
Last Modified: 2016-08-17
I am trying to build a little powershell script that will export all users mailboxes in a particular OU to PST on a file server but i am having a little difficulty sperating the information i need to automate.

import-module activedirectory
$ou = "OU=Window Lickers,DC=domain,DC=Local"
$Users = Get-ADUser -ResultSetSize 3000 -SearchBase $ou -filter * | ForEach-Object {$_.Name, $_.UserPrincipalName}
foreach ($user in $users)
##In here i want to be able to export each mailbox to a specific path. I was hoping to use this but it doesnt seem to work.
New-MailboxExportRequest -Mailbox $_.UserPrincipalName -FilePath "\\vm1\archives\NewArchives\" $_.Name

Any help on this is appreciated.
Question by:CaptainGiblets
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
  • 2
LVL 17

Accepted Solution

Ivan earned 1000 total points
ID: 41757641

maybe you can try with this, running from Exchange Shell.

$Export = Get-Mailbox -OrganizationalUnit Test
$Export|%{$_|New-MailboxExportRequest -FilePath "\\servername\pst\$($_.alias).pst"}

It is a modification from https://social.technet.microsoft.com/wiki/contents/articles/13908.bulk-export-mailboxes-to-pst-in-exchange-2010.aspx


Assisted Solution

by:David Sankovsky
David Sankovsky earned 1000 total points
ID: 41757647
I have something that works well for hosted exchange.
If said OU happens to have a different UPN, can try this:

$Export=Get-Mailbox -ResultSize unlimited | where {$_.primarysmtpaddress -like "*@upn.tld"}
foreach ($i in ($Export)) {New-MailboxExportRequest -Mailbox $i -Filepath "\\servername\sharename\$($i.PrimarySmtpAddress).pst" }

Open in new window


Expert Comment

by:Senior IT System Engineer
ID: 41758706

Is that powershell command also exports the archived email as well to PST ?

Expert Comment

by:David Sankovsky
ID: 41758902
Is that powershell command also exports the archived email as well to PST ?

No, only the mailbox itself, to export the archives as well, modify the script like so:

$Export=Get-Mailbox -ResultSize unlimited | where {$_.primarysmtpaddress -like "*@upn.tld"}
foreach ($i in ($Export)) {New-MailboxExportRequest -Mailbox $i -Filepath "\\servername\sharename\$($i.PrimarySmtpAddress)_archive.pst" -IsArchive }

Open in new window


Expert Comment

by:Senior IT System Engineer
ID: 41758995
You see Awesome David :-)

Featured Post

Are your AD admin tools letting you down?

Managing Active Directory can get complicated.  Often, the native tools for managing AD are just not up to the task.  The largest Active Directory installations in the world have relied on one tool to manage their day-to-day administration tasks: Hyena. Start your trial today.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

How to deal with a specific error when using the Enable-RemoteMailbox cmdlet to create a mailbox in the cloud-based service, for an existing user in an on-premises Active Directory.
With so many activities to perform, Exchange administrators are always busy in organizations. If everything, including Exchange Servers, Outlook clients, and Office 365 accounts work without any issues, they can sit and relax. But unfortunately, it…
The video tutorial explains the basics of the Exchange server Database Availability groups. The components of this video include: 1. Automatic Failover 2. Failover Clustering 3. Active Manager
Exchange organizations may use the Journaling Agent of the Transport Service to archive messages going through Exchange. However, if the Transport Service is integrated with some email content management application (such as an antispam), the admini…
Suggested Courses

618 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question