Sharepoint Foundation 2013: Create Search Service App

How many of us had a fresh installation of SharePoint Foundation 2013 and tried to create the Search Service App trough Central Admin and didn't find it? I'm sure than more people than only me :)

Once we are in this situation, we have two possible options

  • Use SharePoint Wizard to create Search Service App
  • Use Powershell

The first option I prefer to discard it, obvious is obvious 😛

So, in the next lines I will post the code I use to create Search Service App

We have to type the account used for the AppPools, the name of the search servce application and the name of the AppPool, as it can be seen I the code, it has been take it from other blog (Thanks :))

[string]$farmAcct = "DomAppPool"
[string]$serviceAppName = "SearchServiceApplication"

Function WriteLine
{
Write-Host -ForegroundColor White “————————————————————–”
}

# ———————————————————————
Function ActivateAndConfigureSearchService
{
Try
{
# Based on this script : http://blog.falchionconsulting.com/index.php/2013/02/provisioning-search-on-sharepoint-2013-foundation-using-powershell/

Write-Host -ForegroundColor White ” –> Configure the SharePoint Foundation Search Service -“, $env:computername
Start-SPEnterpriseSearchServiceInstance $env:computername
Start-SPEnterpriseSearchQueryAndSiteSettingsServiceInstance $env:computername
$appPool = Get-SPManagedAccount -Identity $farmAcct

New-SPServiceApplicationPool -Name AppServicesAppPool -Account $appPool -Verbose
$saAppPool = Get-SPServiceApplicationPool -Identity AppServicesAppPool
$svcPool = $saAppPool
$adminPool = $saAppPool

$searchServiceInstance = Get-SPEnterpriseSearchServiceInstance $env:computername
$searchService = $searchServiceInstance.Service
$bindings = @(“InvokeMethod”, “NonPublic”, “Instance”)
$types = @([string],
[Type],
[Microsoft.SharePoint.Administration.SPIisWebServiceApplicationPool],
[Microsoft.SharePoint.Administration.SPIisWebServiceApplicationPool])

$values = @($serviceAppName,
[Microsoft.Office.Server.Search.Administration.SearchServiceApplication],
[Microsoft.SharePoint.Administration.SPIisWebServiceApplicationPool]$svcPool,
[Microsoft.SharePoint.Administration.SPIisWebServiceApplicationPool]$adminPool)

$methodInfo = $searchService.GetType().GetMethod(“CreateApplicationWithDefaultTopology”, $bindings, $null, $types, $null)
$searchServiceApp = $methodInfo.Invoke($searchService, $values)
$searchProxy = New-SPEnterpriseSearchServiceApplicationProxy -Name “$serviceAppName – Proxy” -SearchApplication $searchServiceApp
$searchServiceApp.Provision()

}
catch [system.exception]
{
Write-Host -ForegroundColor Yellow ” ->> Activate And Configure Search Service caught a system exception”
Write-Host -ForegroundColor Red “Exception Message:”, $_.Exception.ToString()
}
finally
{
WriteLine
}
}

ActivateAndConfigureSearchService

That’s all!

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