Monday, February 2, 2015

Search Service Application creation using Powershell


# Getting  Search Application from Each Server.

$AppServer = get-SPServiceInstance -server VSPIAPP | ?{$_.TypeName -eq "SharePoint Server Search"}
$WEFServer = get-SPServiceInstance -server VSPIWEF | ?{$_.TypeName -eq "SharePoint Server Search"}

#Start our services

Start-SPEnterpriseSearchServiceInstance -Identity $AppServer
Start-SPEnterpriseSearchServiceInstance -Identity $WEFServer

#Create our App Pools

$acct = get-spmanagedaccount "abc\SerchSerivceSVC"
$Admin = new-SPServiceApplicationPool -name "Search_Admin_Pool" -account $Acct
$Query = new-SPServiceApplicationPool -name "Search_Query_Pool" -account $Acct


#Create the Search Service Application

$SA = New-SPEnterpriseSearchServiceApplication -Name "IP Search Service Application" -applicationpool $Admin -databasename "<<Database_Name>>"



#Create the proxy and associate it

$SProxy = new-spenterprisesearchserviceapplicationproxy -name "IP Search Service Application Proxy" -SearchApplication $SA



#Get a clone to work with
$ST = $SA.ActiveTopology.Clone()

#Input each component of the topology into our clone



New-SPEnterpriseSearchAdminComponent -SearchServiceInstance $AppServer -SearchTopology $ST

New-SPEnterpriseSearchContentProcessingComponent -SearchServiceInstance $AppServer -SearchTopology $ST

New-SPEnterpriseSearchAnalyticsProcessingComponent -SearchServiceInstance $AppServer -SearchTopology $ST

New-SPEnterpriseSearchCrawlComponent -SearchServiceInstance $AppServer -SearchTopology $ST


New-SPEnterpriseSearchIndexComponent -SearchServiceInstance $WEFServer -SearchTopology $ST

New-SPEnterpriseSearchQueryProcessingComponent -SearchServiceInstance $WEFServer -SearchTopology $ST

$ST.Activate()


$username = read-host "User name"
$password = read-host -assecurestring  "Password"


Set-SPEnterpriseSearchServiceApplication –Identity $SA -ApplicationPool $Query -DefaultContentAccessAccountName $UserName -DefaultContentAccessAccountPassword $Password.