====== Microsoft Exchange Server ======
See also **[[internet:mail:exchange:exchange_virt|Virtualizing Exchange Server]]**
See also **[[internet:mail:moving_to_new_mailserver|Migrating to a New Mail Server]]**
See also **http://www.mustbegeek.com/configure-url-redirection-in-exchange-2013/**
===== Services Status =====
Get-Service | Where {$_.DisplayName -Like "*Exchange*"} | ft DisplayName, Name, Status
===== Shut Down and Restart Exchange Services =====
==== Exchange 2013 ====
Stop Services:
Get-service -name "msexchange*" -dependentservices | Where-Object {$_.Status -eq 'Running'} | Stop-Service
Start Services:
Get-service -name "msexchange*" -dependentservices | Where-Object {$_.Status -eq 'stopped'} | Start-Service
Using ''net stop'':
net stop msexchangeadtopology /y
net stop msexchangefba /y
net stop msftesql-exchange /y
net stop msexchangeis /y
net stop msexchangesa /y
net stop HostControllerService
net stop MSExchangeHM
net stop MSExchangeDiagnostics
net stop MSExchangeADTopology
net stop FMS
and ''net start'':
net start FMS
net start MSExchangeADTopology
net start MSExchangeDiagnostics
net start MSExchangeHM
net start HostControllerService
net start msexchangeIS
net start msexchangeServiceHost
net start msexchangeMailboxAssistant
net start msexchangeDelivery
net start msexchangeSubmission
net start msexchangeMailboxReplication
net start msexchangeTransport
net start msexchangeTransportLogSearch
net start msexchangeThrottling
net start msexchangeFrontEndTransport
net start msexchangeFastSearch
net start msexchangeRPC
net start msexchangeUM
net start msexchangeUMCR
net start msexchangeEdgeSync
net start msexchangeDAGMgmt
net start msexchangeRepl
net start msexchangeAntiSPAMUpdate
net start msexchangeIMAP4
net start msexchangeIMAP4BE
==== Exchange 2007 ====
net stop msexchangeadtopology /y
net stop msftesql-exchange /y
net stop msexchangeis /y
net stop msexchangesa /y
net stop iisadmin /y
net start "World Wide Web Publishing Service"
net start "Microsoft Exchange Information Store"
net start "Microsoft Exchange System Attendant"
net start "Microsoft Search (Exchange)"
net start "Microsoft Exchange Information Store"
net start "Microsoft Exchange Unified Messaging"
net start "Microsoft Exchange Transport Log Search"
net start "Microsoft Exchange Transport"
net start "Microsoft Exchange Service Host"
net start "Microsoft Exchange Search Indexer"
net start "Microsoft Exchange Replication Service"
net start "Microsoft Exchange Mail Submission"
net start "Microsoft Exchange Mailbox Assistants"
net start "Microsoft Exchange File Distribution"
net start "Microsoft Exchange EdgeSync"
net start "Microsoft Exchange Anti-spam Update"
===== Errors =====
**Diagnostic-Code: smtp;550 5.7.1 RESOLVER.RST.AuthRequired; authentication required**
The email problems I was having where with Distribution Groups I had created in Exchange 2007 under Recipient Group, then under Distribution Group, You have to go to the properties of the email account in question and go under the TAB “Mail flow settings”. There under Message Delivery Restrictions make sure that there is NO check mark box inside of "require that all senders are authenticated”.
===== Move Mailboxes to Another Database =====
https://www.petenetlive.com/KB/Article/0001224
Database maintenance operations such as offline defragmentation take so long that it is often recommended to simply **create a new database, move mailboxes (online) to the new database, then delete the old database** instead.
To prevent disk-full problems, **enable Circular Logging** before (or during) your mailbox migration and **restart the 'Microsoft Exchange Information Store' service**. **Mailbox migration creates huge numbers of log files!**
**Exchange Admin Center -> Servers -> Databases -> -> Edit -> Maintenance -> Enable Circular Logging -> Save**
Set-MailboxDatabase -CircularLoggingEnabled $True
net stop "Microsoft Exchange Information Store"
net start "Microsoft Exchange Information Store"
===== Restore Deleted Mailbox =====
https://www.phy2vir.com/restore-a-deleted-mailbox-in-exchange-2013/
Show recently deleted databases:
Get-MailboxDatabase | Get-MailboxStatistics | Where {$_.DisconnectReason -eq "Disabled"} | fl DisplayName,MailboxGuid,LegacyDN,Database,TotalItemSize
Restore a recently deleted mailbox (recreate destination user and mailbox first):
Set the mailbox quota to a high enough value on the destination mailbox or the restore will fail.
New-MailboxRestoreRequest -SourceStoreMailbox -SourceDatabase -TargetMailbox -AllowLegacyDNMismatch -LargeItemLimit Unlimited -AcceptLargeDataLoss
Get-MailboxRestoreRequest | Get-MailboxRestoreRequestStatistics
==== Restore Failures ====
https://docs.microsoft.com/en-us/powershell/module/exchange/mailboxes/resume-mailboxrestorerequest
Status of restore requests:
Get-MailboxRestoreRequest | Get-MailboxRestoreRequestStatistics
Collect details of failed restore requests:
Get-MailboxRestoreRequest -Status failed | Get-MailboxRestoreRequestStatistics -IncludeReport | format-list > c:\users\"username"\restore_report.txt
Set-MailboxRestoreRequest -Identity "Identity" -LargeItemLimit Unlimited -AcceptLargeDataLoss
Always use ''New-MailboxRestoreRequest'', but you can try the older ''Restore-Mailbox'' as a fallback.
Cleanup:
Get-MailboxRestoreRequest -Status Completed | Remove-MailboxRestoreRequest
===== Mailbox Recovery =====
:!: **You may need to do a database repair first**!
https://gallery.technet.microsoft.com/office/Recover-mailbox-from-edb-0635d717
https://www.nucleustechnologies.com/blog/how-to-restore-exchange-2016-mailboxes/
===== Database Repair =====
**Database repair operations will use a huge amount of disk space and create huge temp files!** You can cause greater problems than you already have if you ignore this!
**Database defrag and repair takes a very long time!** If you have a 200GB database, you might get it back up tomorrow! ''eseutil /p'' and ''eseutil /d'' run at about 3-5GB of data per hour.
**Do not make any mistakes** or you might not get it back up tomorrow!
**Recovery Plan Outline**: http://forums.msexchange.org/fb.aspx?m=1800504795
http://msexchangeguru.com/2013/02/01/jet_errmissinglogfile-528-548/
http://www.msexchange.org/articles-tutorials/exchange-server-2003/tools/Exchange-ISINTEG-ESEUTIL.html
http://msexchangeguru.com/2011/03/02/databse-repair/
http://msexchangeguru.com/2009/07/12/exchange-database-recovery-using-eseutil-commands/
http://exchangeserverpro.com/restore-individual-mailbox-exchange-2010#eseutil
:!: If you can, you might consider shutting down all Exchange services at this point.
Check "state" of database:
eseutil /mh "C:\Program Files\Microsoft\Exchange Server\V14\Mailbox\Mailbox Database\Mailbox Database.edb"
If the state is "clean shutdown", move all the log files from the Transaction logs folder location and then mount the stores.
If Dirty:
Check log files:
eseutil /ml "C:\Program Files\Microsoft\Exchange Server\V14\Mailbox\Mailbox Database\E00"
:!: Add ''/a'' to skip **missing logfile**.
If the log files are healthy, then perform the Soft recovery:
eseutil /r E00 /l "C:\Program Files\Microsoft\Exchange Server\V14\Mailbox\Mailbox Database" /d "C:\Program Files\Microsoft\Exchange Server\V14\Mailbox\Mailbox Database\Mailbox Database.edb"
If the soft recovery runs without error but the state is still dirty, you can run a full recovery:
:!: Make a backup of the database first!
eseutil /p "C:\Program Files\Microsoft\Exchange Server\V14\Mailbox\Mailbox Database\Mailbox Database.edb"
:!: If you only plan to salvage data from the disk, and do not plan to put it back in production, you can skip defragmentation to save time.
Now we defragment the database:
If you don't specify the temporary space, you had better have a very large C: drive and it will probably **fill it completely causing even bigger problems**! It is recommended to have 110% of the database size in free temp space.
The Exchange ''eseutil /d'' defragment temp file location defaults to ''%windir%\System32\'' and the files are named ''xxxxxxx.EDB'' and ''xxxxxxx.INTEG.RAW''.
If you can, such as in a virtualized environment, **consider adding a very large and very fast drive just for temporary space**.
After running ''/d'', **you must remove any log files** before mounting the database.
eseutil /d /t
eseutil /d "C:\Program Files\Microsoft\Exchange Server\V14\Mailbox\Mailbox Database\Mailbox Database.edb" /t "E:\TempDefrag.edb"
Now we logically repair the database and reindex:
:!: The ''MSExchangeIS'' service must be running and the database dismounted.
:!: This command is gone as of Exchange 2013.
isinteg -s servername -fix -test alltests
===== Database Recovery =====
:!: **If you can, restore the mailboxes without restoring from backup**.
Here we have **restored the database and log files from backup**:
Check for Clean Shutdown:
eseutil /mh "x:\path\to\restored\mailboxdb.edb"
Create a new recovery database in Exchange using the restored databse file and logs:
New-MailboxDatabase -Recovery -Name RecoveryDB -Server SERVERNAME -EdbFilePath "x:\path\to\restored\mailboxdb.edb" -LogFolderPath "x:\path\to\restored\logs\"
Get-MailboxStatistics -Database RecoveryDB | ft –auto
===== Recover Mailbox from Recovery Database =====
https://converteredbtopst.wordpress.com/2017/08/29/export-mailbox-from-recovery-database-exchange-2013-to-pst/
Get-MailboxStatistics -Database RecoveryDB | where displayname -eq "User Name"
:!: You must add ''-AllowLegacyDNMismatch'' if you merge to a new account.
:!: Add ''-TargetRootFolder'' if desired.
New-MailboxRestoreRequest -SourceDatabase RecoveryDB -SourceStoreMailbox "SourceUser Name" -TargetMailbox "TargetUser Name" -AllowLegacyDNMismatch -TargetRootFolder "Restored Items"
Get-MailboxRestoreRequest | Get-MailboxRestoreRequestStatistics
Cleanup:
Get-MailboxRestoreRequest -Status Completed | Remove-MailboxRestoreRequest
===== Export Mailbox to PST =====
:!: To export to PST, you must recover the mailbox first.
New-MailboxExportRequest -Mailbox username -FilePath \\server\share\path\username.pst
Get-MailboxExportRequest | Get-MailboxExportRequestStatistics
===== Rebuild Search Index =====
https://practical365.com/exchange-server/exchange-2016-failed-content-index/
:!: Rebuilding the search index will cause **high CPU load**.
Get-MailboxDatabaseCopyStatus * | sort name | Select name,status,contentindexstate
Stop-Service MSExchangeFastSearch
Stop-Service HostControllerService
Get-MailboxDatabase
Get-MailboxDatabase "Mailbox Database 000000000" | select EdbFilePath
Using File Manager, **delete the sub-folder with a GUID for the name** containing the content index files.
Start-Service MSExchangeFastSearch
Start-Service HostControllerService
Wait a while, then recheck the ''contentindexstate''. The status will change to ''crawling''.
===== Check Version =====
https:///mapi/emsmdb/
or
Get-ExchangeServer | fl name,AdminDisplayVersion
Then cross-reference here:
https://social.technet.microsoft.com/wiki/contents/articles/15776.exchange-server-2013-2016-and-2019-build-numbers-with-cumulative-updates.aspx
===== Troubleshooting =====
Exchange database consistency check (for full backup):
eseutil /k /i "C:\Program Files\Microsoft\Exchange Server\V14\Mailbox\Mailbox Database\Mailbox Database.edb"
https://testconnectivity.microsoft.com/