Monday, April 23, 2018

Create new Search topology on single server

Parameters to change:
$AppServer = write your app server name
$IndexLocation = location of index. It would be best to put index on other partition then your system data. Do not forget to check if you already have this location created and if you have check if it is empty.
$SearchAppPoolAccountName = write your account
$DatabaseServer = database server name. Check do you have default instance (e.g. servername) or named instance (e.g. servername\instancename)
$DatabaseName = name of Search app database

Script:

********************************

Add-PsSnapin Microsoft.SharePoint.PowerShell -ErrorAction SilentlyContinue

#Defaults
$AppServer = "SERVERNAME"
$IndexLocation = "E:\SharePointSearch"  #!!!!!Do not forget to check if you already have this location created and if you have check if it is empty!!!!!
$SearchAppPoolName = "SearchServiceAppPool"
$SearchAppPoolAccountName = "YourDomain\sp_content"
$SearchServiceName = "Search Service Application"
$SearchServiceProxyName = "Search Service Application Proxy"
$DatabaseServer = "DatabaseServer\InstanceName"
$DatabaseName = "SearchServiceApplication_DB"

#Create ApplicationPool
Write-Host "Creating Application Pool..."
$spAppPool = New-SPServiceApplicationPool -Name $SearchAppPoolName -Account $SearchAppPoolAccountName -Verbose

#Start Search Instances
Write-Host "Starting Search Service Instances..."
Start-SPEnterpriseSearchServiceInstance $AppServer -ErrorAction SilentlyContinue
Start-SPEnterpriseSearchQueryAndSiteSettingsServiceInstance $AppServer -ErrorAction SilentlyContinue

#Create Application
Write-Host "Creating Search Service Application..."
$searchServiceApp = New-SPEnterpriseSearchServiceApplication -Partitioned -Name $SearchServiceName -ApplicationPool $spAppPool.Name -DatabaseServer $DatabaseServer -DatabaseName $DatabaseName

#Create proxy
Write-Host "Creating Search Service Application Proxy..."
New-SPEnterpriseSearchServiceApplicationProxy -Partitioned -Name $SearchServiceProxyName -SearchApplication $searchServiceApp

#Clone the default Topology...create a new one...and then activate it
Write-Host "Configuring Search Component Topology..."
$clone = $searchServiceApp.ActiveTopology.Clone()
$searchServiceInstance = Get-SPEnterpriseSearchServiceInstance -Identity $AppServer

#Create new topoplogy
#Create Admin component
New-SPEnterpriseSearchAdminComponent –SearchTopology $clone -SearchServiceInstance $searchServiceInstance
#Create content processing component
New-SPEnterpriseSearchContentProcessingComponent –SearchTopology $clone -SearchServiceInstance $searchServiceInstance
#Create Analytics processing component
New-SPEnterpriseSearchAnalyticsProcessingComponent –SearchTopology $clone -SearchServiceInstance $searchServiceInstance
#Create Crawl component
New-SPEnterpriseSearchCrawlComponent –SearchTopology $clone -SearchServiceInstance $searchServiceInstance
#Create Index component
New-SPEnterpriseSearchIndexComponent –SearchTopology $clone -SearchServiceInstance $searchServiceInstance
#Create Query processing component
New-SPEnterpriseSearchQueryProcessingComponent –SearchTopology $clone -SearchServiceInstance $searchServiceInstance


#Activate topology
$clone.Activate()

Write-Host "Search topology successfully created!"

********************************

No comments:

Post a Comment