1

I'm attempting to streamline the development environment setup process for a large development team. A lot of the setup process is already automated, e.g. we automatically create a Solr Docker container with all the necessary cores.

We make heavy use of indexes and would prefer to avoid having to ask/demo to the developer to manually rebuild their indexes from the Sitecore Control panel.

I could rebuild manually, or via a Sitecore scheduled task but how can I script a Solr index rebuild, ideally from Windows Powershell?

  • you can create a page (rebuildindex.aspx?your-params) that will do indexing and you can call it using powershell script. – Vipin Banka Sep 17 at 10:04
4

To rebuild indexes from sitecore powershell you can use below script which will re-index all indexes one by one

using namespace Sitecore.ContentSearch

$indexes = [ContentSearchManager]::Indexes

foreach($index in $indexes){
    Write-Host "Re-indexing started " $index.Name
    $index.Rebuild([IndexingOptions]::ForcedIndexing);
    Write-Host "Re-indexing Finished" $index.Name    
}

If you want to rebuild indexes using Windows Powershell only then you should enable remoting services first and then execute script

You can refer this link for enabling remoting services - https://sitecore.stackexchange.com/a/2665/1606

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.