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?
I use the following function to generically grab an app pool object:
$query = "Select * From IIsApplicationPoolSetting WHERE WAMUserName LIKE '%$uServer'"
$query
$pools = Get-WmiObject -Authentication 6 -ComputerName $server -Query $query -Namespace 'root/microsoftiisv2'
if ($pools)
{
foreach ($pool in $pools)
{
Write-Host(" WAM Pool: " + $pool.Name + ", " + $pool.WAMUserName + " (" + $pool.WAMUserPass + ")")
}
}
And from an unrelated piece of code, here's where I place a site in a new App Pool. It's just an example how to use Set-WMIInstance.
if ($site.AppPoolID -ne $poolID)
{
# Write-Host("Updating $($site.Name) from $($site.AppPoolID) to $($poolID)")
$wmiArgs = @{"AppPoolID"=$poolID}
[void](Set-WMIInstance -InputObject $site -Arguments $wmiArgs)
} else {
# Write-Host("No update needed")
}
Use Get-Member to learn what properties your $pool has, then use Set-WMIInstance to modify them.