EXPORT .PST files from mailboxes every day - how to setup a schedule
Hello -
I am running exchange 2013 - I would like to know if you can please help me figure out a way to export .pst from mailboxes for example I have a mailbox name sam and I wanted to know the command to run in order to export that mailbox into .pst into my backup
drive every night at 1AM.
Thanks.-- Still learning
December 3rd, 2012 7:27am
Hi
Just run powershell script with New-MailboxExportRequest from task scheduler
You need to have Impor Export Mailbox Role and export mailbox to share not local disc
New-MailboxExportRequest -Mailbox "John Smith" -FilePath \\server\share\JSmith.pst
Remigiusz
ExchangeBlog
Free Windows Admin Tool Kit Click here and download it now
December 3rd, 2012 12:39pm
Hi,WCWS,
Do you only want to export one mailbox or all mailboxes to a PST file?
Regardless of this,you can run the export powershell scripts in the schedule but make sure you have add confirm $false to avoid a manually break with pressing Y to continute.
And for the all mailboxes exporting you can run the following command
Get-Mailbox Database "<servername\database name>" | Export-Mailbox PSTFolderPath <folder path for export> -Confirm $false
In addition,some old similar threads for your reference.
http://social.technet.microsoft.com/Forums/hu/exchange2010/thread/622e610c-9c3a-42a6-b66d-a06b601c19bc
http://social.technet.microsoft.com/Forums/en/exchangesvradminlegacy/thread/11eabb21-95f7-4b33-bb34-f9cc05c38785
Regards,
SharonSharon Shen
TechNet Community Support
************************************************************************************************************************
Please remember to click Mark as Answer on the post that helps you, and to click Unmark as Answer if a marked post does not actually answer your question.
December 4th, 2012 9:43am
Hi
check also this post about export/import mailboxes
Exchange 2010 export import mailboxes
Remigiusz
ExchangeBlog
Free Windows Admin Tool Kit Click here and download it now
December 4th, 2012 12:14pm
Will this script work on ECK 2013
# Exchange 2010 SP1 Mailbox Export Script
# Steve Goodman. Use at your own risk!
###############
# Settings #
###############
# Pick ONE of the two below. If you choose both, it will use $Server.
$Server = "server"
$Database = ""
# Share to export mailboxes to. Needs R/W by Exchange Trusted Subsystem
# Must be a UNC path as this is run by the CAS MRS service.
$ExportShare = "\\server\share"
# After each run a report of the exports can be dropped into the directory specified below. (The user that runs this script needs access to this share)
# Must be a UNC path or the full path of a local directory.
$ReportShare = "\\server\share"
# Shall we remove the PST file, if it exists beforehand? (The user that runs this script needs access to the $ExportShare share)
# Valid values: $true or $false
$RemovePSTBeforeExport = $false
###############
# Code #
###############
if ($Server)
{
if (!(Get-ExchangeServer $Server -ErrorAction SilentlyContinue))
{
throw "Exchange Server $Server not found";
}
if (!(Get-MailboxDatabase -Server $Server -ErrorAction SilentlyContinue))
{
throw "Exchange Server $Server does not have mailbox databases";
}
$Mailboxes = Get-Mailbox -Server $Server -ResultSize Unlimited
} elseif ($Database) {
if (!(Get-MailboxDatabase $Database -ErrorAction SilentlyContinue))
{
throw "Mailbox database $Database not found"
}
$Mailboxes = Get-Mailbox -Database $Database
}
if (!$Mailboxes)
{
throw "No mailboxes found on $Server"
}
if (!$Mailboxes.Count)
{
throw "This script does not support a single mailbox export."
}
# Pre-checks done
# Make batch name
$date=Get-Date
$BatchName = "Export_$($date.Year)-$($date.Month)-$($date.Day)_$($date.Hour)-$($date.Minute)-$($date.Second)"
Write-Output "Queuing $($Mailboxes.Count) mailboxes as batch '$($BatchName)'"
# Queue all mailbox export requests
foreach ($Mailbox in $Mailboxes)
{
if ($RemovePSTBeforeExport -eq $true -and (Get-Item "$($ExportShare)\$($Mailbox.Alias).PST" -ErrorAction SilentlyContinue))
{
Remove-Item "$($ExportShare)\$($Mailbox.Alias).PST" -Confirm:$false
}
New-MailboxExportRequest -BatchName $BatchName -Mailbox $Mailbox.Alias -FilePath "$($ExportShare)\$($Mailbox.Alias).PST"
}
Write-Output "Waiting for batch to complete"
# Wait for mailbox export requests to complete
while ((Get-MailboxExportRequest -BatchName $BatchName | Where {$_.Status -eq "Queued" -or $_.Status -eq "InProgress"}))
{
sleep 60
}
# Write reports if required
if ($ReportShare)
{
Write-Output "Writing reports to $($ReportShare)"
$Completed = Get-MailboxExportRequest -BatchName $BatchName | Where {$_.Status -eq "Completed"} | Get-MailboxExportRequestStatistics | Format-List
if ($Completed)
{
$Completed | Out-File -FilePath "$($ReportShare)\$($BatchName)_Completed.txt"
}
$Incomplete = Get-MailboxExportRequest -BatchName $BatchName | Where {$_.Status -ne "Completed"} | Get-MailboxExportRequestStatistics | Format-List
if ($Incomplete)
{
$Incomplete | Out-File -FilePath "$($ReportShare)\$($BatchName)_Incomplete_Report.txt"
}
}
-- Still learning
December 4th, 2012 3:39pm
Yes it should do, I've not tried it though. Let me know how you get on ;-)Steve Goodman
Check out my Blog for more Exchange info or find me on
Twitter
Free Windows Admin Tool Kit Click here and download it now
December 6th, 2012 12:34am
Hi,
Any updates here?
Regards,
SharonSharon Shen
TechNet Community Support
************************************************************************************************************************
Please remember to click Mark as Answer on the post that helps you, and to click Unmark as Answer if a marked post does not actually answer your question.
December 17th, 2012 5:32am