Solved

Exchange powershell mass exporting to PST

Posted on 2016-08-16
5
59 Views
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.
1
Comment
Question by:CaptainGiblets
[X]
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
5 Comments
 
LVL 17

Accepted Solution

by:
Ivan earned 250 total points
ID: 41757641
Hi,

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

Regards,
Ivan.
0
 
LVL 7

Assisted Solution

by:David Sankovsky
David Sankovsky earned 250 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

1
 
LVL 8

Expert Comment

by:Senior IT System Engineer
ID: 41758706
David,

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

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

1
 
LVL 8

Expert Comment

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

Featured Post

Enroll in June's Course of the Month

June's Course of the Month is now available! Every 10 seconds, a consumer gets hit with ransomware. Refresh your knowledge of ransomware best practices by enrolling in this month's complimentary course for Premium Members, Team Accounts, and Qualified Experts.

Question has a verified solution.

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

In-place Upgrading Dirsync to Azure AD Connect
The Nano Server Image Builder helps you create a custom Nano Server image and bootable USB media with the aid of a graphical interface. Based on the inputs you provide, it generates images for deployment and creates reusable PowerShell scripts that …
This video shows how to quickly and easily add an email signature for all users on Exchange 2016. The resulting signature is applied on a server level by Exchange Online. The email signature template has been downloaded from: www.mail-signatures…
There are cases when e.g. an IT administrator wants to have full access and view into selected mailboxes on Exchange server, directly from his own email account in Outlook or Outlook Web Access. This proves useful when for example administrator want…

690 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