https://social.msdn.microsoft.com/Forums/en-US/580660b4-3d9e-4605-a28b-3407089caceb/how-to-configure-application-pool-identity-from-powershell?forum=iisconfiguationandscripting
$appPoolPath = “iis:\AppPools\foo”
$appPool = new-item $appPoolPath
$appPool | set-itemproperty -Name “managedRuntimeVersion” -Value “v2.0”
$appPool | set-itemproperty -Name “managedPipelineMode” -Value “Classic”
function AppPoolConfiguration{
param ([System.String]$applicationPoolName)
$pool = Get-Item “IIS:\AppPools\ASP.NET v4.0”;
#set Enable 32bit Applications
$pool.enable32BitAppOnWin64 = “True”
Log-Info “IIS App pool $pool settings changed: enable32BitAppOnWin64 = True”
#set Pipeline mode
$pool.managedPipelineMode = 0
Log-Info “IIS App pool $pool settings changed: managedPipelineMode = Integrated”
#set Identity
$pool.processModel.username = “reasult\test_lt”
$pool.processModel.password = “2jDsEGih”
$pool.processModel.identityType = 3
Log-Info “IIS App pool $pool settings changed: Identity = $pool.processModel.username”
#set Idle Time-out
$pool.processModel.idleTimeout = “06:00:00”
Log-Info “IIS App pool $pool settings changed: idleTimeout = $pool.processModel.idleTimeout”
#Save
$pool | set-item
}
AppPoolConfiguration $installedWebApplication.applicationPool;