@ECHO OFF CLS SETLOCAL ENABLEDELAYEDEXPANSION SET /A RETRY_IMAP=0 SET /A MAX_RETRIES=3 SET EXCH_IMAP= MSExchangeImap4 REM To check current status of the service. :check_imap SC QUERY %EXCH_IMAP% | FIND "RUNNING" >NUL IF %ERRORLEVEL%==0 ( ECHO Exchange IMAP4 Service is Running. GOTO end ) REM To start the service if the status is stopped. ECHO Exchange IMAP4 Service is Stopped. SC START %EXCH_IMAP% TIMEOUT /T 10 >NUL REM To re-check the service status again for confirmation. SC QUERY %EXCH_IMAP% | FIND "RUNNING" >NUL IF %ERRORLEVEL%==0 ( ECHO Exchange IMAP4 Service is Running. GOTO end ) REM Retrying to start the service with a maximum of 3 retries only. SET /A RETRY_IMAP+=1 IF !RETRY_IMAP! LSS %MAX_RETRIES% ( ECHO Retrying Start %EXCH_IMAP% (Attemp: !RETRY_IMAP!). GOTO check_imap ) ELSE ( ECHO Max Retries Reached for %EXCH_IMAP%, will stop retrying. GOTO end ) :end EXIT |
Apr 15, 2025
Windows 10/11 : Batch File to Start and Check Windows Services
Dec 15, 2022
Exchange Server 2016 : Command Line
1. Get-ExchangeServer | Format-List Name,Edition,AdminDisplayVersion
2. Get-MailboxDatabase -Status | Select Name,LastFullBackup
3. Get-AuthConfig | fl CurrentCertificateThumbPrint
4. Get-ExchangeCertificate
Exchange Server 2016 : Outlook Search Not Working
Microsoft Exchange Server 2016 : Outlook Search Not Working.
This issue happen when the "Content Index State" is either corrupted or incorrect.
1. Open --> Exchange Management Shell
2. Get-MailboxDatabaseCopyStatus * | sort name | Select name,status,contentindexstate
3. If the "Content Index State" = FailedandSuspended = Corrupted.
4. Stop-Service MSExchangeFastSearch
5. Stop-Service HostControllerService
6. Get-MailboxDatabase [DB Name] | select EdbFilePath
7. Open --> File Explorer --> Browse to [EDB Path] (eg. F:\Program Files\Microsoft\Exchange Server\V15\Mailbox\Mailbox Database)
8. Find a Sub-Folder with a GUID Name (eg. C5B6A9C4-DDA8-xxxx-xxx), DELETE the entire Sub-Folder.
9. Start-Service MSExchangeFastSearch
10. Start-Service HostControllerService
11. It will take some times to regenerate the index, be patient.
12. To check status --> Get-MailboxDatabaseCopyStatus * | sort name | Select name,status,contentindexstate
13. The status should either be "Crawling" = Work-in-Progress or "Healthy" = Good.
!!! HAPPY COMPUTING !!!