Category Archives: Exchange 2010

Export all mailboxes

Copy this to a .ps1 and run it :

######
#    Choose option yes/no
######

$title = “Export mailboxes from Exchange 2010 SP1+”
$message = “Do you want to Export All Mailboxes?”

$yes = New-Object System.Management.Automation.Host.ChoiceDescription “&Yes”, “Export all Mailboxes on the Exchange server.”

$no = New-Object System.Management.Automation.Host.ChoiceDescription “&No”, “Don’t want to Export all Mailboxes.”

$options = [System.Management.Automation.Host.ChoiceDescription[]]($yes, $no)

$result = $host.ui.PromptForChoice($title, $message, $options, 0)

if ($result -eq “0”) {

$script:SharedPath = Read-Host “Enter UNC path for pst-folders”

######
#    Test if sharedpath exists
######

$Path = $script:SharedPath

if (Test-Path $Path) {
Write-Host “SharedFolder OK…!” -ForeGroundColor Green
}

else {
Write-Host “SharedFolder doesn’t exists…! ” -ForeGroundColor Red
break
}

######
#    Export Mailboxes
######
$colitems = Get-mailbox
Foreach($objitem in $colitems) {

Write-host “Start Exporting mailboxes” -ForeGroundColor Green

New-MailboxExportRequest -Mailbox $objItem -FilePath “$Path$objitem.pst”;
}
}

if ($result -eq “1”) {

clear
Write-host “Stop Exporting mailboxes” -ForeGroundColor Red
}