SSA SharePoint Foundation 2013 via PowerShell script

This is powershell script for creating and configuring complete “Search Service Application” via powershell console, dont forget to run powershell console under Administrator permission. Try to read and understand whole script before u use it. There is need to put some information in it to make this task done.

#Start the search service instance on the server

Start-SPEnterpriseSearchServiceInstance $env:computername
Start-SPEnterpriseSearchQueryAndSiteSettingsServiceInstance $env:computername
 
#Give a unique name to your search service application
$serviceAppName = "Search Service Application"
 
#Get the application pools to use (make sure you change the value for your environment)
$svcPool = Get-SPServiceApplicationPool "SharePoint Web Services System"
$adminPool = Get-SPServiceApplicationPool "SharePoint Web Services System"
 
#Get the service from the service instance so we can call a method on it
$searchServiceInstance = Get-SPEnterpriseSearchServiceInstance –Local
$searchService = $searchServiceInstance.Service
 
#Define your unique DB names without the guids
$adminDB = "SW_Spoint_Serach_Service_Application_DB"
$propertyStoreDB = "SW_Spoint_Search_Service_Application_PropertyStoreDB"
$crawlStoreDB = "SW_Spoint_Search_Service_Application_CrawlStoreDB"
$analysticsStoreDB = "SW_Spoint_Search_Service_Application_AnalyticsStoreDB"
$linkStoreDB = "SW_Spoint_Search_Service_Application_LinkStoreDB"
 
#Since this method takes in the value of object type Microsoft.SharePoint.Administration.SPDatabaseParameters we will create these from our clean DB names
$adminDBParameters = [Microsoft.SharePoint.Administration.SPDatabaseParameters]::CreateParameters($adminDB,"None")
$propertyDBParameters = [Microsoft.SharePoint.Administration.SPDatabaseParameters]::CreateParameters($propertyStoreDB,"None")
$crawlStoreDBParameters = [Microsoft.SharePoint.Administration.SPDatabaseParameters]::CreateParameters($crawlStoreDB,"None")
$analyticsStoreDBParameters = [Microsoft.SharePoint.Administration.SPDatabaseParameters]::CreateParameters($analysticsStoreDB,"None")
$linkStoreDBParameters = [Microsoft.SharePoint.Administration.SPDatabaseParameters]::CreateParameters($linkStoreDB,"None")
 
#Create the search service application by calling the function
$searchServiceApp = $searchService.CreateApplication($serviceAppName, $adminDBParameters, $propertyDBParameters, $crawlStoreDBParameters, $analyticsStoreDBParameters, $linkStoreDBParameters, [Microsoft.SharePoint.Administration.SPIisWebServiceApplicationPool]$svcPool, [Microsoft.SharePoint.Administration.SPIisWebServiceApplicationPool]$adminPool)
 
#Create the search service application proxy as usual (luckily PowerShell for this works and is bot blocked)
$searchProxy = New-SPEnterpriseSearchServiceApplicationProxy -Name "$serviceAppName Proxy" -SearchApplication $searchServiceApp
#Provision the search service application
$searchServiceApp.Provision()
 
#Get an updated handle on the SearchServiceInstance
$searchServiceInstance = Get-SPEnterpriseSearchServiceInstance –Local
#Now we will call the method to initiate the default topology component creation using reflection
$bindings = @("InvokeMethod", "NonPublic", "Instance")
$types = @([Microsoft.Office.Server.Search.Administration.SearchServiceInstance])
$values = @([Microsoft.Office.Server.Search.Administration.SearchServiceInstance]$searchServiceInstance)
$methodInfo = $searchServiceApp.GetType().GetMethod("InitDefaultTopology", $bindings, $null, $types, $null)

$searchTopology = $methodInfo.Invoke($searchServiceApp, $values)​

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s