Need Script to recycle the app pool in IIS

Hi Team,

I need script for the following concern, Thanks in advance

As per our environment we have more IIS server, we used to recycle app pool in a timely manner after the web deployment

Right now i am doing manually like login into each server and recycle the particular app pool

I need to powershell script to restart the IIS app pool from a single server into many application site.

Example: I have site which is hosted same in four different server for load balance.

I need to restart the particular apppool from remotely for all the serversusing powershell script.

Please letme know if any...

  • As is often said on forums. Forums are not free code writing services. Though forum members are always here to help those trying to make thing work.

    What you are asking here is not new and there are plenty of examples available, built-in to PoSH and online.

    1 - What have you tried so far?

    2 - What have you written that is not working.

    3 - Show you code, and detail errors or issues you are facing.

    4 - Have you looked at the public script repositories for samples...

         the MS PowerShellGallery or the ScritpngGuys blog

    .. or a general web search using you posts' title.

         powershell 'Script to recycle the app pool in IIS'

    ... you will get many hits on this topic.

    Then the is the PoSH built-in and online-help, specifically the Web Administration cmdlets.

    Web Server (IIS) Administration Cmdlets in Windows PowerShell

    Lots of built-in help

        # load the web modules
        Import-Module -Name WebAdministration

        # Lit all modules
        Get-Command -Module WebAdministration

        # list only the WebPool modules
        (Get-Command -Module WebAdministration) -match 'pool' | Format-Table -AutoSize

        CommandType Name                Version Source          
        ----------- ----                ------- ------          
        Cmdlet      Get-WebAppPoolState WebAdministration
        Cmdlet      New-WebAppPool WebAdministration
        Cmdlet      Remove-WebAppPool WebAdministration
        Cmdlet      Restart-WebAppPool WebAdministration
        Cmdlet      Start-WebAppPool WebAdministration
        Cmdlet      Stop-WebAppPool WebAdministration

        # Get parameters, examples, full and Online help for a cmdlet or function
        (Get-Command -Name Restart-WebAppPool).Parameters
        Get-help -Name Restart-WebAppPool -Examples
        Get-help -Name Restart-WebAppPool -Full
        Get-help -Name Restart-WebAppPool -Online