When we need to create a Search Service using user interface following is the process -
1)      Go to ->Central administration
2)      Go to ->Manage Services on server
3)      Start “SharePoint Server Search” service
4)      Application management -> Manage Service applications
5)      New Service application
6)      Specify accounts + app pool names and proxy servers
7)      We may get errors and time-out exceptions
So we can use POWERSHELL to create and configure SEARCH SERVICE with a single click
  • We have to specify INDEX location
  • App pool name
  • Account to use in search service
  • Server name
  • Database name
  • Proxy name
 Please find the script below, it will run in PowerShell window. Remember to run it as “Administrator” privileges.
# Create a new Search Service Application in SharePoint 2013
Add-PSSnapin Microsoft.SharePoint.PowerShell -ErrorAction SilentlyContinue
# Settings
$IndexLocation = “C:\SearchFolder\Search15Index” #Location must be empty, will be deleted during the process!
$SearchAppPoolName = “Search App Pool”
$SearchAppPoolAccountName = “DEV\administrator”
$SearchServerName = (Get-ChildItem env:computername).value
$SearchServiceName = “Search15″
$SearchServiceProxyName = “Search15 Proxy”
$DatabaseName = “Search15_ADminDB”
Write-Host -ForegroundColor Yellow “Checking if Search Application Pool exists”
$SPAppPool = Get-SPServiceApplicationPool -Identity $SearchAppPoolName -ErrorAction SilentlyContinue
if (!$SPAppPool)
   Write-Host -ForegroundColor Green “Creating Search Application Pool”
   $spAppPool = New-SPServiceApplicationPool -Name $SearchAppPoolName -Account $SearchAppPoolAccountName -Verbose

# Start Services search service instance
Write-host “Start Search Service instances….”
Start-SPEnterpriseSearchServiceInstance $SearchServerName -ErrorAction SilentlyContinue
Start-SPEnterpriseSearchQueryAndSiteSettingsServiceInstance $SearchServerName -ErrorAction SilentlyContinue

Write-Host -ForegroundColor Yellow “Checking if Search Service Application exists”
$ServiceApplication = Get-SPEnterpriseSearchServiceApplication -Identity $SearchServiceName -ErrorAction SilentlyContinue

if (!$ServiceApplication)
   Write-Host -ForegroundColor Green “Creating Search Service Application”
   $ServiceApplication = New-SPEnterpriseSearchServiceApplication -Partitioned -Name $SearchServiceName -ApplicationPool $spAppPool.Name -DatabaseName $DatabaseName

Write-Host -ForegroundColor Yellow “Checking if Search Service Application Proxy exists”
$Proxy = Get-SPEnterpriseSearchServiceApplicationProxy -Identity $SearchServiceProxyName -ErrorAction SilentlyContinue
if (!$Proxy)
   Write-Host -ForegroundColor Green “Creating Search Service Application Proxy”
   New-SPEnterpriseSearchServiceApplicationProxy -Partitioned -Name $SearchServiceProxyName -SearchApplication $ServiceApplication

Write-Host $ServiceApplication.ActiveTopology

# Clone the default Topology (which is empty) and create a new one and then activate it
Write-Host “Configuring Search Component Topology….”
$clone = $ServiceApplication.ActiveTopology.Clone()
$SSI = Get-SPEnterpriseSearchServiceInstance -local
New-SPEnterpriseSearchAdminComponent –SearchTopology $clone -SearchServiceInstance $SSI
New-SPEnterpriseSearchContentProcessingComponent –SearchTopology $clone -SearchServiceInstance $SSI
New-SPEnterpriseSearchAnalyticsProcessingComponent –SearchTopology $clone -SearchServiceInstance $SSI
New-SPEnterpriseSearchCrawlComponent –SearchTopology $clone -SearchServiceInstance $SSI

Remove-Item -Recurse -Force -LiteralPath $IndexLocation -ErrorAction SilentlyContinue
mkdir -Path $IndexLocation -Force
New-SPEnterpriseSearchIndexComponent –SearchTopology $clone -SearchServiceInstance $SSI -RootDirectory $IndexLocation
New-SPEnterpriseSearchQueryProcessingComponent –SearchTopology $clone -SearchServiceInstance $SSI
Write-host “The Search Service Application $SearchServiceName is now ready”


Popular Posts