The below script will helps to sort the progess percentage of content index seeding and also number of log files pending for replication. The output of the file will be saved in the desktop and also it will sent as email with an attachment
# Where to store output
$savefile = $env:USERPROFILE + ‘\Desktop\’ +((Get-Date).ToString(“dd_MM_yyyy_HHmm”))+’.html’
#Preformat HTML document
$a = “<style>”
$a = $a + “BODY{background-color:peachpuff;}”
$a = $a + “TABLE{border-width: 1px;border-style: solid;border-color: black;border-collapse: collapse;}”
$a = $a + “TH{border-width: 1px;text-align: center; margin: 2px;padding: 0px;border-style: solid;border-color: black;background-color:thistle}”
$a = $a + “TD{border-width: 1px;text-align: center; margin: 2px;padding: 0px;border-style: solid;border-color: black;background-color:PaleGoldenrod}”
$a = $a + “</style>”
# Function to for the Output
$Output = Get-MailboxServer | Get-MailboxDatabaseCopyStatus | ?{($_.CopyQueueLength -ne “0”) -or ($_.ContentIndexState -ne “Healthy”)} |Select Name,Copyqueuelength,ContentIndexSeedingPercent,ContentIndexState | Sort-Object CopyQueueLength -desc | ConvertTo-Html -head $a -body “<H2>Exchange 2013 Content Index Status</H2>”
$Report = $Output |Out-File $savefile
# This will open report in your default browser.
Invoke-Item $savefile
#To Send Email
$MailTo = “Raji.Subramanian@mail.com”
$MailFrom = “Admin@mail.com”
$MailServer = “Exserver.mail.com”
Send-MailMessage -Attachments $savefile -To $MailTo -From $MailFrom -Subject “Exchange 2013 Content index Status Report” -Body ( $Output | out-string ) -bodyashtml -SmtpServer $MailServer
To add them in the task schedule copy the below command and paste them in the command of new task
C:\Windows\System32\WindowsPowerShell\v1.0\Powershell.exe -Command “.’E:\Program Files\Microsoft\Exchange Server\V15\Bin\RemoteExchange.ps1′; Connect-ExchangeServer -auto; C:\Scripts\CI_Status.ps1