User Tools

Site Tools


Hier findet ihr ein Script um die Mailbox eines Accounts in ein pst File zu exportieren. Der Account wird abgefragt und der Mailboxexportjob gestartet und überwacht bis er fertig ist und der verbliebene Job wird vom Exchangesystem gelöscht.

This is a simple Powershell script to export the Mailbox from one Account
The script will export the Mailbox from a selected Account to a Networkdrive.
You have to enter the UserID to exported first
Then enter the UserID of Account in wich to Import it.
$User1 = Read-Host -Prompt 'UserID of Account to be exported'
#$User2 = Read-Host -Prompt 'UserID of Account to be imported'
$Servername = "Servername"
$date = (Get-Date).ToString("_yyyyMMdd")
Add-PSSnapin Microsoft.Exchange.Management.PowerShell.E2010
#Defining Source and Destination path
$DestPath = "\\$Servername\UserExport$\$date\$User1"
$Mailbox = (get-aduser $User1 -Properties CanonicalName).CanonicalName
New-Item -Path $DestPath -ItemType directory
#Creating new folder for storing backup
Write-Host "Set Permissions on Destinationfolder" -foreground "yellow"
$ACL = Get-Acl "$DestPath"
$ACL.AddAccessRule((New-Object System.Security.AccessControl.FileSystemAccessRule("\Exchange Trusted Subsystem","FullControl","ContainerInherit, ObjectInherit", "None", "Allow")))
Set-Acl "$DestPath" $ACL
Write-Host "Start MailboxexportRequest" -foreground "yellow"
New-MailboxExportRequest -Mailbox $User1 -FilePath "$DestPath\mailboxexport_$User1.pst"
Write-Host "Mailboxexport is getting done to File: "$DestPath\mailboxexport_$user1.pst"" -foreground "yellow"
$Mailbox = (get-aduser $User1 -Properties CanonicalName).CanonicalName
Get-MailboxExportRequest -Mailbox $Mailbox -Status completed
if ($Time) {clear-variable -name Time}
$Time = (Get-Date).ToLongTimeString()
	$checkcompleted = Get-MailboxExportRequest -Mailbox $Mailbox -Status completed
	start-sleep -s 10
                Write-Host "Export is still running" -foreground "yellow"
Write-Host "Mailboxexport is done, we have to wait a Moment" -foreground "yellow"
Get-MailboxExportRequest -status Completed | Remove-MailboxExportRequest -Confirm:$False
Write-Host "Completed Exportjob deleted" -foreground "yellow"
This website uses cookies. By using the website, you agree with storing cookies on your computer. Also you acknowledge that you have read and understand our Privacy Policy. If you do not agree leave the website.More information about cookies
export_einer_mailbox.txt · Last modified: 2017/01/17 10:43 by clemens