«

»

May 13

PS One-Liner: #4 Recycle and schedule Appools periodic restart

This will come in handy if you want to recycle specific or all AppPools which are consuming too much memory on the server. Of course you also want to avoid the memory problems in the future and don’t want to click every AppPool and set the periodic restart schedule. PowerShell to the rescue with just one simple one-liner for each operation. First you have to load the webadministration provider and load the IIS: drive map.

Then you can list (ls = get-childitem) all AppPool items under the IIS provider and match the ones matching ‘Lync’. Enclose the whole command in parenthesis which allows you to execute a method on the “Microsoft.IIs.PowerShell.Framework.ConfigurationElement” object named “Recycle” and there you go, that’s it.

Now you execute the same listing code from above and instead of recycling you set the IIS Recycling property with ‘sp’ (set-itemproperty) to a value of 04:00 which stands for 04:00 AM. Now every day all application pools are freshly recycled and are starting up for a brand new day.