Office365 - Move Mailbox and Export to PST

Hi Everyone

So we have moved all our Mailboxes to Office365 and I am in the process of setting up our service desk checklists etc.

One issue that i have came across is that it is not possible to directly export mailboxes from Exchange Online to PST.

We are in a Hybrid Environment so it is still possible to migrate mailboxes off to a local Mailbox Server and export from there.

In order to streamline this as much as possible i have written the following (UnTested!) script.  I will be using it from the Azure Powershell Module already connected to our online tenant and so that section of code has been removed.

If anyone had any thoughts in regards to this - or can point out any glaringly obvious mistakes that would be great!

#Script to Move User MailBox from Exchange Online to OnPrem and Export To PST
#Created By: Joe McGrath
#Created On: 17/12/2013

#Mailbox move

$OnpremCred=get-credential
$User= Read-Host 'Enter the username of the user'
new-moverequest -identity $User -OutBound -RemoteTargetDatabase 'YOURDB' -RemoteHostName mail.YOURDOMAIN.com -RemoteCredential $OnpremCred -TargetDeliveryDomain YOURDOMAIN.com
#The Next Section Checks the Status of the move every 60 seconds
$MoveStatus=""
$MoveStatus = Get-MoveRequest -Identity $User
do
{
    Start-Sleep -Seconds 60
    $MoveStatus = Get-MoveRequest -Identity $User
}
While ($MoveStatus.Status -ne 'Completed')

Write-Host "Mailbox Move Completed."
#When the Move has completed we now clear the move request
Remove-MoveRequest -identity $User
Write-Host "Move Request Cleared from System"

#This next section will carry out the Export to PST
#We need to call the Exchange 2010 Powershell cmdlets and connect to the On Premises Exchange Infrastructure to Export to PST

Write-host "Connecting to On Premises Exchange"
$ExchangeSession = New-PSSession -ConfigurationName Microsoft.Exchange -ConnectionUri "http://Server.YOURDOMAIN.local/PowerShell" -Credential $OnpremCred
Import-PSSession $ExchangeSession
$filePath='\\Server\Share\'

#This First Command Exports the Users Primary Mailbox to PST
Write-Host "Beginning Primary Mailbox Export to PST for "+$User
New-MailboxExportRequest -Mailbox $User -FilePath $filePath+$User+".pst"

$MailboxExportStatus=""
$MailboxExportStatus = Get-MailboxExportRequestStatistics -Identity $User
Do
{
    Start-Sleep -Seconds 60
    $MailboxExportStatus = Get-MailboxExportRequestStatistics -Identity $User
}
While ($MailboxExportStatus.Status -ne 'Completed')

Remove-MailboxExportRequest -Identity $User

Write-Host "The Primary Mailbox for "+$User+" Has been exported."
Write-Host "Exporting Archive Mailbox for "+$User

#This Command Exports the Users Archive to PST
Write-Host "Exporting Archive Mailbox for "+$User
New-MailboxExportRequest -Mailbox $User -IsArchive -FilePath $filePath+$User+"_Archive.pst"
$ArchiveExportStatus=""
$ArchiveExportStatus = Get-MailboxExportRequestStatistics -Identity $User
Do
{
    Start-Sleep -Seconds 60
    $ArchiveExportStatus = Get-MailboxExportRequestStatistics -Identity $User
}
While ($ArchiveExportStatus.Status -ne 'Completed')

Remove-MailboxExportRequest -Identity $User

Write-Host "The Archive Mailbox for "+$User+" Has been exported."
Remove-PSSession $ExchangeSession
Write-Host "User Mailbox has been Removed from Online and Archived to file"

Like I said this is not tested yet - I need an account to test with - after I manually migrate the data first :) - so use at your own risk etc

December 17th, 2013 2:56pm

Hi,

You can not export the Office365 mailbox Data in to PST, you must have to bring the mailbox to on premises and then export, once done again move back the mailbox to office365,

another way is from in-place hold, search the mailbox and take users PST, or user third party tool such as messageops which is quite good.


Free Windows Admin Tool Kit Click here and download it now
April 20th, 2015 10:08am

This topic is archived. No further replies will be accepted.

Other recent topics Other recent topics