I want to disable the idle timeout (Set it to Zero) of an application pool and I want to perform this at setup time, is it possible to perform this action from C# or PowerShell?
Here is a complete Powershell sample showing how to create an application pool (for ASP.NET Core) and set many of its values:
Import-Module WebAdministration
$appPoolName = "MyWebPool"
$appPoolFullName = "IIS:\AppPools\$appPoolName"
if(!(Test-Path $appPoolFullName)) {
New-WebAppPool $appPoolName -Force
Set-ItemProperty $appPoolFullName -Name managedPipelineMode -Value Integrated
Set-ItemProperty $appPoolFullName -Name managedRuntimeVersion -Value "" # means "No Managed Code"
Set-ItemProperty $appPoolFullName -Name startMode -Value AlwaysRunning
$3_days = New-TimeSpan -Days 3
Set-ItemProperty $appPoolFullName -Name processModel.idleTimeout -Value $3_days
Set-ItemProperty $appPoolFullName -Name processModel.identityType -Value NetworkService
Set-ItemProperty $appPoolFullName -Name processModel.idleTimeoutAction -Value Suspend
$zero_ts = New-TimeSpan
Set-ItemProperty $appPoolFullName -Name recycling.periodicRestart.time -Value $zero_ts
}