Solved

Exchange powershell mass exporting to PST

Posted on 2016-08-16
5
45 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
  • 2
  • 2
5 Comments
 
LVL 15

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 6

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 7

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 6

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 7

Expert Comment

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

Featured Post

Threat Intelligence Starter Resources

Integrating threat intelligence can be challenging, and not all companies are ready. These resources can help you build awareness and prepare for defense.

Join & Write a Comment

Disabling the Directory Sync Service Account in Office 365 will stop directory synchronization from working.
Exchange server is not supported in any cloud-hosted platform (other than Azure with Azure Premium Storage).
In this video we show how to create an Accepted Domain in Exchange 2013. We show this process by using the Exchange Admin Center. Log into Exchange Admin Center.: First we need to log into the Exchange Admin Center. Navigate to the Mail Flow >> Ac…
To add imagery to an HTML email signature, you have two options available to you. You can either add a logo/image by embedding it directly into the signature or hosting it externally and linking to it. The vast majority of email clients display l…

762 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

Need Help in Real-Time?

Connect with top rated Experts

17 Experts available now in Live!

Get 1:1 Help Now