Skip to content

Instantly share code, notes, and snippets.

@michaellwest
Created September 8, 2015 01:15
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save michaellwest/4118c8c285fcaf927e98 to your computer and use it in GitHub Desktop.
Save michaellwest/4118c8c285fcaf927e98 to your computer and use it in GitHub Desktop.
Rebuild all of the Sitecore content search indexes with a progress dialog.
Get-SearchIndex | Rebuild-SearchIndex -IncludeRemoteIndex
$jobs = [Sitecore.Jobs.JobManager]::GetJobs() | Where-Object { !$_.IsDone -and $_.Category -eq "Indexing" } | Sort-Object -Property Name
$jobsCount = $jobs.Count
while(($jobs | Where-Object { !$_.IsDone })) {
$progressCount = 0
$message = New-Object System.Text.StringBuilder
foreach($job in $jobs) {
$message.AppendLine("$($job.Name) is $($job.Status.State) and processed: $($job.Status.Processed)") | Out-Null
if($job.Status.State -ne "Running") {
$progressCount++
}
}
Write-Progress -Activity "Rebuilding indexes" -Status $message -PercentComplete ($progressCount/$jobsCount*100) -CurrentOperation "Rebuilding"
Start-Sleep -Milliseconds 500
}
Write-Progress -Activity "Index rebuilds complete." -Completed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment