locked
Setting recycle and process model properties on app pool from powershell RRS feed

  • Question

  • User904176925 posted

    Hi!

    I'm creating an app pool from powershell using the following:

     $pool = New-WebAppPool -Name $name
     $pool.recycling.periodicrestart.time = [TimeSpan]::FromMinutes(0)
     $pool.processModel.idleTimeout = [TimeSpan]::FromMinutes(0)

    The app pool is created but it ignores my values for recycling.periodicrestart.time and processModel.idleTimeout.

    What am I doing wrong here? I'm using a Windows Server 2008 R2 x64 Web Edition and Powershell 2.

    /Måns

    Thursday, May 13, 2010 5:38 AM

All replies

  • User2065605267 posted

    Just for fun, have you tried setting this via the IIS:\ provider?

    http://learn.iis.net/page.aspx/688/using-the-iis-application-warm-up-module/

    Monday, May 17, 2010 11:57 PM
  • User904176925 posted

    Nope! Looks interesting but I do want the powershell stuff to work. It worked just fine in powershell 1 on a Windows 2003 Server so I see no reason to why it should not work now.

    Tuesday, May 18, 2010 1:15 AM
  • User1331732461 posted

    Hi,

    You have created a pool and assign the object to a specific powershell variable.
    Even though you have changed any attribute of the variable, that does not affect the actual apppool object and that is currenly by design. And that can be solved with using Set-ItemProperty as the following:

    $name = "test3"
    $pool = New-WebAppPool -Name $name
    $pool.recycling.periodicrestart.time = [TimeSpan]::FromMinutes(0)
    $pool.processModel.idleTimeout = [TimeSpan]::FromMinutes(0)

    Set-ItemProperty ("IIS:\AppPools\"+$name) -Name recycling.periodicrestart.time $pool.recycling.periodicrestart.time
    Set-ItemProperty ("IIS:\AppPools\"+$name) -Name processModel.idleTimeout $pool.processModel.idleTimeout
    Get-ItemProperty ("IIS:\AppPools\"+$name) -Name recycling.periodicrestart.time.value
    Get-ItemProperty ("IIS:\AppPools\"+$name) -Name processModel.idleTimeout.value

    If you run the above commands, you will see there is a new apppool named "test3" and the periodicrestart and the idletimeout of the apppool is set to 0.

     

    Wednesday, June 2, 2010 1:40 PM