Wednesday, November 27, 2024

HowTo: create Search Sharepoint 2013 Foundation Application via Powershell

Problem: You deleted the Search Service Application in Sharepoint 2013 Foundation and are now unable to recreate it, as your web application is not named “Sharepoint – 80” (so the wizard will not work).

Solution: Microsoft disabled the option to create the DB via powershell for some reasons, but Gary found a solution to perform the tasks via powershell as mentioned here. Here is the code I´m using (similar to Garys one).

What it does:

– Create a new pool (modify the script if you wish to use a existing one)

– Use a existing Service Taskuser which I added via the central administration

– Create the search application and the proxy

Start-SPEnterpriseSearchServiceInstance $env:computername

Start-SPEnterpriseSearchQueryAndSiteSettingsServiceInstance $env:computername
$serviceAppName = "Search Service Application"

$appPool=Get-SPManagedAccount -Identity "Contoso\SpFarmSearch"

New-SPServiceApplicationPool -Name SearchApplicationPool -Account $appPool -Verbose

$saAppPool=Get-SPServiceApplicationPool -Identity SearchApplicationPool

$svcPool = $saAppPool

$adminPool = $saAppPool

$searchServiceInstance = Get-SPEnterpriseSearchServiceInstance –Local

$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()

 

Related Articles

LEAVE A REPLY

Please enter your comment!
Please enter your name here

Stay Connected

35FollowersFollow
- Advertisement -

Latest Articles