This example will require using PowerShell but you could just as easily use C# or some other programming language.
You can run this from the PowerShell command line or bundle up as part of a PowerShell Script.
First load your handy dandy SharePoint Assembly:
[System.Reflection.Assembly]::LoadWithPartialName("Microsoft.SharePoint")
Next, create an object of the site that you want the application pool identity of:
$site = New-Object Microsoft.SharePoint.SPSite("http://www.threewill.com")
Now create a variable to hold the web application information:
$webapp= $site.WebApplication
One more variable to get the Application pool information:
$AppPool= $webapp.ApplicationPool | Out-String (I use the Out-String so I can see the information if I decide to use a script)
Lastly, let's take a look at the application pool information:
write-host $AppPool
It should look something like this:
CurrentIdentityType : SpecificUser
Username : DomanName\SPAccount
Password : YourPassword
SecurePassword : System.Security.SecureString
IsCredentialUpdateEnabled : True
IsCredentialDeploymentEnabled : True
Name : SharePoint - 2222
TypeName : Microsoft.SharePoint.Administration.SPApplicationPool
DisplayName : SharePoint - 2222
Id : a808448d-bbee-417c-9936-12bfac9738de
Status : Online
Parent : SPWebService Parent=SPFarm Name=SharePoint_Config
Version : 9013
Properties : {}
Farm : SPFarm Name=SharePoint_Config
UpgradedPersistedProperties : {}
