So last month I promised some customers I would post mysearch script for 2013 and as life would have it, August came before I got toit so here it is…. Better late than never. While this script is pretty basic as far as provisioning Search forSharePoint 2013 goes it does address two things I always try to do when I provisionsearch that I don’t often see. First, itis designed to use two different service accounts, one for the administrationapplication pool and the other for the query application pool. Second, at the end of the script I put in apiece that sets the content access account to another account which followsbest practice.
This particular code is designed for a standard 3 tier farmthat has an Application, Web and Database server. The idea of the code is to put most of theSearch roles on the Application server. The roles going on the Web server are related to the Query Role andIndex.
Script:
#Setup Variables - Assume 2 Servers (App & Web)
#Assume 3 Accounts (Content Access, Admin, Query)
#### Note - You should setup the Index Location prior torunning these commands and ensure it is an empty folder
#### Note - If you setup diag logging prior to runningscript, ensure you give dbo permissions to the account you run this under
write-host 0. Setting up some initial variables.
$AppSvr = "SPApp2013"
$WebSvr = "SPWeb2013"
$CAAcct = "campbushnell\svcSPSearchCA"
$password = "ZAQ!2wsx"
$CAAcctPW = ConvertTo-SecureString -String $password-AsPlainText -Force
$AdminAcct = "campbushnell\svcSPSearchA"
$QueryAcct = "campbushnell\svcSPSearchQ"
$SSAName = "EnterpriseSearch"
$SSIAppSvr = get-SPServiceInstance -server $AppSvr |?{$_.TypeName -eq "SharePoint Server Search"}
$SSIWebSvr = get-SPServiceInstance -server $WebSvr |?{$_.TypeName -eq "SharePoint Server Search"}
$IndexLocation = "C:\SPIndexLocation"
$err = $null
#Start Services for SSI
write-host 1. Start Services search services for Each Server
Start-SPEnterpriseSearchServiceInstance -Identity $SSIAppSvr
Start-SPEnterpriseSearchServiceInstance -Identity $SSIWebSvr
#Create Application Pools
write-host 2. Create a Application Pools
$AdminAppPool = new-SPServiceApplicationPool -name$SSAName"-AdminAppPool" -account $AdminAcct
$QueryAppPool = new-SPServiceApplicationPool -name$SSAName"-QueryAppPool" -account $QueryAcct
#Create Search Service Application
write-host 3. Create the SearchApplication and set it to avariable
$SearchApp = New-SPEnterpriseSearchServiceApplication -Name$SSAName -applicationpool $AdminAppPool -databasename$SSAName"_AdminDB"
#Create Search Service Application Proxy
write-host 4. Create search service application proxy
$SSAProxy = new-spenterprisesearchserviceapplicationproxy-name $SSAName"ApplicationProxy" -SearchApplication $SearchApp
#Clone Search Topology (this is empty by default)
write-host 5. Clone Search Topology
$SearchTopology = $SearchApp.ActiveTopology.Clone()
#Provision Search Administration Component
write-host 6. Provision Search Admin Component.
New-SPEnterpriseSearchAdminComponent -SearchServiceInstance$SSIAppSvr -SearchTopology $SearchTopology
#Provision New Search Content Processing Component
write-host 7. Create New Search Content Processing Component
New-SPEnterpriseSearchContentProcessingComponent-SearchServiceInstance $SSIAppSvr -SearchTopology $SearchTopology
#Provision New Search Analytics Processing Component
write-host 8. Create New Search Analytics ProcessingComponent
New-SPEnterpriseSearchAnalyticsProcessingComponent-SearchServiceInstance $SSIAppSvr -SearchTopology $SearchTopology
#Provision New Search Crawl Component
write-host 9. Create New Search Crawl Component
New-SPEnterpriseSearchCrawlComponent -SearchServiceInstance$SSIAppSvr -SearchTopology $SearchTopology
#Provision New Search Index Component
write-host 10. Create New Search Index Component
New-SPEnterpriseSearchIndexComponent -SearchServiceInstance$SSIWebSvr -SearchTopology $SearchTopology -RootDirectory $IndexLocation
#Provison New Query Processing Component
write-host 11. Create New Query Processing Component
New-SPEnterpriseSearchQueryProcessingComponent-SearchServiceInstance $SSIWebSvr -SearchTopology $SearchTopology
#Activate Topology Changes
write-host 12. Activate Topology
$SearchTopology.Activate()
#Setup default Content Access Account
write-host 13. Set the default content access account
Set-SPEnterpriseSearchServiceApplication –Identity$SearchApp -ApplicationPool $QueryAppPool -DefaultContentAccessAccountName$CAAcct -DefaultContentAccessAccountPassword $CAAcctPW
Write-host "Your search application $SSAName is nowready"
One last note with this script, it is designed for smallerfarms and if a large search farm is being created more configuration will berequired to ensure you get the performance you are looking for.
Thank you very much mate..