SBS2011, resp. Exchange 2010 a export mailboxu do PST ze zálohy

Peklo na zemi. Zálohy prováděné Windows Backupem. Víc snad už nemám sílu psát.

# Obnovit z Windows Backup zalohy aplikaci Exchange do adresare D:\Recovery

eseutil /mh 'D:\Recovery\D_\Exchange Server\V14\Mailbox\Mailbox Database\Mailbox Database.edb'

eseutil /ml 'D:\Recovery\D_\Exchange Server\V14\Mailbox\Mailbox Database\E00'

eseutil /r E00 /l 'D:\Recovery\D_\Exchange Server\V14\Mailbox\Mailbox Database' /s 'D:\Recovery\D_\Exchange Server\V14\Mailbox\Mailbox Database' /d 'D:\Recovery\D_\Exchange Server\V14\Mailbox\Mailbox Database’

eseutil /mh 'D:\Recovery\D_\Exchange Server\V14\Mailbox\Mailbox Database\Mailbox Database.edb' | findstr "State:"

# Pokud není Clean Shutdown, ale Dirty Shutdown, tak pustit následující dva příkazy
eseutil /p 'D:\Recovery\D_\Exchange Server\V14\Mailbox\Mailbox Database\Mailbox Database.edb'
eseutil /mh 'D:\Recovery\D_\Exchange Server\V14\Mailbox\Mailbox Database\Mailbox Database.edb' | findstr "State:"

IF NOT EXIST D:\Recovery\D_\Exchange Server\V14\Mailbox-RecoveryDB (MKDIR 'D:\Recovery\D_\Exchange Server\V14\Mailbox-RecoveryDB')

New-MailboxDatabase RecoveryDB -Server SBS -Recovery:$true -EdbFilePath 'D:\Recovery\D_\Exchange Server\V14\Mailbox\Mailbox Database\Mailbox Database.edb' -LogFolderPath 'D:\Recovery\D_\Exchange Server\V14\Mailbox-RecoveryDB'

Mount-Database RecoveryDB

Get-MailboxStatistics -Database RecoveryDB

# Vytahnout si jmeno uzivatele, ktereho chci exportovat
# Vytvorit docasneho uzivatele "exmerge" v produkcni Exchange databazi

New-Mailbox -Alias exmerge -Name "exmerge" -FirstName exmerge -DisplayName "exmerge" -UserPrincipalName exmerge@domena.tld -OrganizationalUnit 'CN=Users,DC=domena,DC=tld'

New-MailboxRestoreRequest -SourceDatabase RecoveryDB -SourceStoreMailbox "Exportovany Uzivatel" -TargetMailbox "exmerge" -AllowLegacyDNMismatch -WhatIf

Get-MailboxRestoreRequest
# Opakovat prubezne tak dlouho, dokud neni hotovo

# Pokud predtim nikdy nebyl pouzit "exmerge", tak vytvorit Universal Security Group v AD s nazvem treba "Exmerge adminusers"
# Pridat do teto skupiny administratora, pod kterym pracuji
New-ManagementRoleAssignment -Role "Mailbox Import Export" -SecurityGroup "Exmerge adminusers"
# Zavrit a otevrit okno Exchange Management Shellu, aby se uplatnilo nove prirazeni prav

# Priprava sdilene slozky pro export dat do PST
IF NOT EXIST d:\exmerge_data (MKDIR d:\exmerge_data)
NET SHARE exmerge_data$=D:\exmerge_data /GRANT:Everyone,FULL /CACHE:None
ICACLS d:\exmerge_data /GRANT "Exchange Trusted Subsystem":(OI)(CI)(M)

New-MailboxExportRequest -Mailbox exmerge -FilePath \\SERVER\exmerge_data$\obnovovany-user_recovered.pst

Get-MailboxExportRequest
# Opakovat prubezne tak dlouho, dokud neni hotovo

# Odstraneni RecoveryDB
Dismount-Database RecoveryDB
Remove-MailboxDatabase RecoveryDB
rmdir /S /Q d:\Recovery

# Odstraneni exmerge uzivatele
Remove-MailUser exmerge

To je strašný. Prostě strašný.