Install/OnPrem/Solr/Create-CustomSolrCores.ps1

. "$PSScriptRoot\..\..\InstallParams.ps1" -Force
. "$PSScriptRoot\SolrParams.ps1" -Force
$ErrorActionPreference = "Stop"

Write-Output "Add custom Solr cores started..."

if (($null -eq $global:Configuration.search.solr.customCores) -or ($global:Configuration.search.solr.customCores.Count -lt 1)) {
    Write-Warning "No custom Solr cores found."
}
else {
    $prefix = $global:Configuration.prefix
    $configPath = "$PSScriptRoot\custom-solr.json"
    $solrService = $global:Configuration.search.solr.install.serviceName

    foreach ($index in $global:Configuration.search.solr.customCores) {
        $solrParams = @{
            Path        = $configPath
            SolrUrl     = $SolrServiceURL
            SolrRoot    = $SolrServiceDir
            SolrService = $solrService
            CorePrefix  = $prefix  
            CoreName    = $index.name
        }
        Install-SitecoreConfiguration @solrParams
    }
}

Write-Output "Add custom Solr cores done."