0

I am using this Powershell script for Coveo indexing, but I do not see the output after waiting for a long time. I can see that indexing is running in "Coveo indexing manager". But its not completing or giving any messages. Could anyone suggest about this issue?

using namespace Sitecore.ContentSearch
$indexes = [ContentSearchManager]::Indexes
foreach($index in $indexes){
   if($index.Name  -match  "Coveo")
   {
    Write-Host "Re-indexing started " $index.Name
    $index.Rebuild([IndexingOptions]::ForcedIndexing);
    Write-Host "Re-indexing Finished" $index.Name 
   }
}
1

Explanation

When you take a look at signature of Rebuild method you will notice that it's void which means it doesn't return any value, handle, nothing.

Technically you received what you asked for because you've only asked index to be rebuilded.


Solution

If you want to track progress in PowerShell you need to modify your code a little bit.

Here is an example how you can rebuild sitecore_core_index index and track progress in PowerShell.

# get index object
$index = [Sitecore.ContentSearch.ContentSearchManager]::Indexes | ? { $_.Name -eq "sitecore_core_index" }
# invoke index rebuild and get job handle
$job = $index | Initialize-SearchIndex -AsJob

# while job is running display job status with 1 second delay
while ($job.Status.State -eq "Running") {
    $job.Status
    Start-Sleep -Seconds 1
}

Results

Script - console output enter image description here

Jobs Viewer (https://sc/sitecore/admin/jobs.aspx) enter image description here

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.