How to Rebuild Exchange Index

This process involves removing the existing content index files, which will trigger Exchange Search to re-index that database. The re-indexing process can cause a high load on the Exchange server, which may impact performance for the server. So you should carefully consider the timing of any content index rebuilds, and how it might impact your end users. The content index files are located in the same path as the database EDB file, in a sub-folder named with a GUID.


Before the corrupt index files can be removed, the Exchange Search services must be stopped. While these services are stopped, searches in OWA will not be able to be performed by end users, and all of the database content indexes on the server will be reported as “Failed” by Get-MailboxDatabaseCopyStatus.

1PS C:\> Invoke-Command -ComputerName EX2013SRV1 {Stop-Service MSExchangeFastSearch; Stop-Service HostControllerService}

Next, delete the GUID-named folder that contains the content index files. If the folder will not delete due to files in use, then it’s likely that either:

  • You haven’t stopped the correct search services
  • Another process, such as file-level anti-virus software, has a lock on the folder (and may be the cause of the index corrupting to begin with)

After deleting the files, start the search services again.

1PS C:\> Invoke-Command -ComputerName EX2013SRV1 {Start-Service MSExchangeFastSearch; Start-Service HostControllerService}

After a delay while Exchange Search evaluates the situation, the database will be re-indexed. The content index will have a state of “Crawling” while this is occurring.

12345678[PS] C:\>Get-MailboxDatabaseCopyStatus -Server EX2013SRV1 | ft -auto Name            Status  CopyQueueLength ReplayQueueLength LastInspectedLogTime ContentIndexState—-            ——  ————— —————– ——————– —————–DB01EX2013SRV1 Mounted 0               0                                      CrawlingDB02EX2013SRV1 Mounted 0               0                                      HealthyDB03EX2013SRV1 Mounted 0               0                                      HealthyDB04EX2013SRV1 Mounted 0               0                                      Healthy

You can monitor the progress of the database crawl by watching the MSExchange Search IndexesCrawler: Mailboxes Remaining counter in Performance Monitor for that database instance.


Summary :

Get-MailboxDatabaseCopyStatus -Server SRV-EX13.farad.local | ft -auto
locate the database not healthy
Invoke-Command -ComputerName SRV-EX13.farad.local {Stop-Service MSExchangeFastSearch; Stop-Service HostControllerService}
delete folder.single in the exchange folder database correspond to not healthy
Invoke-Command -ComputerName SRV-EX13.farad.local {Start-Service MSExchangeFastSearch; Start-Service HostControllerService}

Exchange Server set up Mail and attachment size

To check your server’s current limit you can open and access them via Exchange Management Console (EMC), however PowerShell offers a faster method that is available also on Office 365. Run the following code in the Exchange Management Shell, or after connecting with Office 365 via remote PowerShell session:

get-transportconfig | ft maxsendsize, maxreceivesize
get-receiveconnector | ft name, maxmessagesize
get-sendconnector | ft name, maxmessagesize
get-mailbox Administrator |ft Name, Maxsendsize, maxreceivesize

To change the above size limits you can use a PS script too. The example below shows how to reduce the size of messages accepted by the transport service from the 25 MB to 15 MB.

Set-TransportConfig -MaxSendSize 15MB -MaxReceiveSize 15MB

Syntax of the command for send/receive connectors is similar, however you need to execute it for each connector’s identity. The same rule applies to mailboxes – you need to specify which mailboxes to affect by the command. Therefore, it is easier to pass over the result of the  Get- command directly to the Set- command. To do so – use the piping feature of PowerShell. E.g. setting a 10MB message size limit in  all mailboxes requires the following command:

Get-Mailbox | Set-Mailbox -MaxSendSize 10MB -MaxReceiveSize 10MB

The Get-mailbox command result is passed with the “|” pipe symbol to the Set-Mailbox command. This method works also for the send/receive connectors. The final script that sets the transport message size limit to 15 MB, send/receive connectors limits to 10 MB each, and the message size limit in all mailboxes to 10 MB presents as follows:

get-transportconfig | Set-TransportConfig -maxsendsize 15MB -maxreceivesize 15MB; get-receiveconnector | set-receiveconnector -maxmessagesize 10MB; get-sendconnector | set-sendconnector -maxmessagesize 10MB; get-mailbox | Set-Mailbox -Maxsendsize 10MB -maxreceivesize 10MB

There is a drawback however. Limits presented above are set for the message as a whole, no matter if they contain attachments or not. If the message is extremely large and contains no attachment, it will be stopped.

Attachment size limit

The only way to set size limits exclusively for attachments is to use a hub transport rule, which will detect and block messages if their attachments are over a specified size threshold.

To set up the rule you can use the below PowerShell script, as the method is quite simple:

New-TransportRule -Name LargeAttach -AttachmentSizeOver 10MB -RejectMessageReasonText "Message attachment size over 10MB - email rejected."

and final

Set-SendConnector -Identity “Default send connector” -MaxMessageSize 5MB

(this for all mailbox. you can use the mailbox instead ‘Default send connector’)

to check after :

get-sendconnector | ft name, maxmessagesize

very usefull this link …Thanks