Sunday 24 September 2017

Power shell to provision Search Service Application

#Set Database and Service Names here - set them as desired
$SearchServiceAppPool = "Search_Service_Application_Pool"
$SearchApplicationName = "Pro SharePoint Search Service Application"
$SearchAdminDatabase = "Search_Service_Admin_Database"
$CrawlDatabase = "Crawl_Database"
$SearchPropertyDatabase = "Search_Property_Database"

#Set the search service instance name in a variable and start the service.
$SearchServiceInstance = Get-SPEnterpriseSearchServiceInstance -local
Start-SPEnterpriseSearchServiceInstance -Identity $SearchServiceInstance
#Set a user for the service and create a new application pool for search
$Search_Service_Account = "Administrator"
$ApplicationPool = new-SPServiceApplicationPool -name $SearchServiceAppPool
–account $Search_Service_Account

#Create the search service application
New-SPEnterpriseSearchServiceApplication -Name $SearchApplicationName
–applicationpool $ApplicationPool -databasename $SearchAdminDatabase

#Create the Search Service Application Proxy
$SearchServiceApplication = Get-SPEnterpriseSearchServiceApplication
New-SPEnterpriseSearchServiceApplicationProxy -name Search_Service_App_Proxy
–Uri $SearchServiceApplication.Uri.AbsoluteURI

#Set the Search Service Administration Component
Set-SPenterpriseSearchAdministrationComponent –SearchApplication
$SearchServiceApplication -searchserviceinstance $SearchServiceInstance

#Create a Crawl topology
$CrawlTopology = $searchserviceApplication | New-SPEnterpriseSearchCrawlTopology

#Create a new crawl database and crawl component and then Set the new Crawl Topology Active
$CrawlDatabase = $searchserviceApplication | New-SPEnterpriseSearchCrawlDatabase
–DatabaseName $CrawlDatabase
New-SPEnterpriseSearchCrawlComponent -CrawlTopology $CrawlTopology –CrawlDatabase
$CrawlDatabase -SearchServiceInstance $SearchServiceInstance
$CrawlTopology | Set-SPEnterpriseSearchCrawlTopology –Active

#Create a new query topology
$QueryTopology = $searchServiceApplication | New-SPEnterpriseSearchQueryTopology -Partitions
1
$Partition = Get-SPEnterpriseSearchIndexPartition -querytopology $QueryTopology
New-SPEnterpriseSearchQueryComponent -indexpartition $Partition –QueryTopology
$QueryTopology -searchserviceinstance $SearchServiceInstance

#Create a database for properties and assign it to the query partition
$PropertyDatabase = New-SPEnterpriseSearchPropertyDatabase -searchapplication
$SearchServiceApplication -databasename $SearchPropertyDatabase
$Partition | Set-SPEnterpriseSearchIndexPartition -PropertyDatabase $PropertyDatabase

#Activate the Query Topology
$QueryTopology | Set-SPEnterpriseSearchQueryTopology -Active

No comments:

Post a Comment