1. How many App Pools are created when you create the Search Service Application?
  2. How can I create all the Search Service Application App Pools using PowerShell and give them all unique names?

I've come across many scripts to create the search service application with a custom Admin App Pool name. The only thing missing in all of these scripts is the ability to also name the Query App Pool like you can do in Central Admin. I'm mainly looking to separate the App Pools and give them all unique names.


There are two search-related service application pools: Admin and Query. Here are the lines of PowerShell I use in my scripts:

# Create the application pools for the Search Admin service and the Search Query service
$apppool_searchadmin = New-SPServiceApplicationPool –name $ap_search_admin –account $account_search_admin
$apppool_searchquery = New-SPServiceApplicationPool –name $ap_search_query –account $account_search_query

New-SPServiceApplicationPool will return the app pool, which I use save to the two variables and use in my script later when needed. I pass it the name of the application pool and a string that contains the account name ("DOMAIN\account") for the application pool.

You can then create the search service with New-SPEnterpriseSearchServiceApplication:

$searchApp = New-SPEnterpriseSearchServiceApplication -Name $searchServiceAppName -ApplicationPool $apppool_searchquery -AdminApplicationPool $apppool_searchadmin -DatabaseName $dbName
  • Could you share how you use the two $apppool variables later in your script? The only command I've seen with an -applicationpool parameter is New-SPEnterpriseSearchServiceApplication, and like the OP I've only come across scripts that apply a single application pool here. Is there a way in that command to specify 2 separate app pools for admin and query, or does that happen elsewhere? – Yohan P Jul 27 '12 at 20:48
  • ... Holy cow, thank you. I have been using that line in my scripts for over a year now and I have never noticed that the query application pool isn't used. I can't find any reference to it outside of the page created in Central Administration. The closest documentation that attempts to explain it is here: blogs.msdn.com/b/sharepoint_strategery/archive/2012/06/29/…, but I still can't figure out how to associate it with the query web service. – shufler Jul 27 '12 at 21:39
  • On one level that's disappointing, but on another level it's reassuring that I'm not crazy :) I guess there really isn't a way in PowerShell to assign 2 different app pools to the admin and query portions of the Search service app then? – Yohan P Jul 28 '12 at 4:43
  • 1
    I see that the New-SPEnterpriseSearchServiceApplication takes two application pool parameters (ApplicationPool and AdminApplicationPool), though the documentation (technet.microsoft.com/en-us/library/ff607751.aspx) is so poor I honestly have no idea what ApplicationPool is for. – shufler Jul 30 '12 at 15:46
  • 2
    So I went ahead and tried it. Here's the relevant script line: $searchApp = New-SPEnterpriseSearchServiceApplication -Name $searchServiceAppName -ApplicationPool $queryAppPool -AdminApplicationPool $adminAppPool -DatabaseName $dbName Worked great. Checked the properties of the service app afterwards, and the 2 app pools were properly assigned. – Yohan P Jul 31 '12 at 19:38
  1. Single Application Pool / the one you indicate when you create the S-SA
  2. See script

    Function Get-SPServiceApplicationPoolByName($SPApplicationPoolName, $ManagedAccount) {

    $appPool = Get-SPServiceApplicationPool | Where {$_.Name -eq $SPApplicationPoolName}

    if($appPool -eq $null) {
        $appPool = New-SPServiceApplicationPool -Name $SPApplicationPoolName -Account $ManagedAccount
    Return $appPool}

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.