SharePoint Stack Exchange is a question and answer site for SharePoint enthusiasts. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

Is there a way to programmatically determine which application pool a service application is using?

Further i would like to get the information about the service account the app pool is using.

share|improve this question
up vote 5 down vote accepted

In powershell use:

Get-SPServiceApplication | FT DisplayName, ApplicationPool

If you want to get the property in your own program you need to get a hold of the Service Application and the cast it to SPIisWebServiceApplication which has the ApplicationPool property

share|improve this answer
Casting the SPServiceApplication to SPIisWebServiceApplication in order to get the Application Pool was just what I needed! Though I'd like to be able to get the user name running the app pool, but it looks like the ManagedAccount property is private. Any ideas? – athom Oct 3 '12 at 14:50
TheColonel please check out my answer as this is providing the username used in the app pool and what name you can look at in the iis manager. The anwser from Per Jakobsen is only showing the information visible in SharePoint, but not inside of IIS on the boxes. – Marco Scheel Mar 28 '13 at 12:28

You can use in PowerShell the following command:

Get-SPServiceApplication | ForEach-Object { $_.ApplicationPool}

This results in the name of the service application and the account of the application pool.

share|improve this answer

You can use the SharePoint Management Shell to get the information:

Get-SPServiceApplication | Select Name, @{Name="SPAppPoolName"; Expression={$_.ApplicationPool.Name}},  @{Name="IISAppPoolName"; Expression={$_.ApplicationPool.Id}}, @{Name="ProcessAccountName"; Expression={$_.ApplicationPool.ProcessAccountName}}

This command uses expressions to extract the desired parts from the app pool.

  • Name = The name of the service application
  • SPAppPoolName = SharePoint is using a dedicated name you can use inside of the CA but that is not visible in the IIS management view
  • IISAppPoolName = This is the ID of the SP app pool and is used as the name of the app pool if you check in the IIS manager on the servers the service app is running on ProcessAccount = This is the service account the app pool is running under

You can check (should not edit) the configuration of the app pool in the applicationHost.config (C:\Windows\System32\inetsrv\config\applicationHost.config). Search for the id or navigate to the xml element "applicationPools".

share|improve this answer

You could use System.Security.Principal.WindowsIdentity.GetCurrent().Name to identify the Identity in which the current application is running. This Link provides a nice utility which displays the identity under which the aspx is run.

Or read this Question :)

Hope it helps

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

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