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
    'technet.microsoft.com/en-us/library/hh867899(v=wps.630).aspx'

    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 1.0.0.0 WebAdministration
        Cmdlet      New-WebAppPool      1.0.0.0 WebAdministration
        Cmdlet      Remove-WebAppPool   1.0.0.0 WebAdministration
        Cmdlet      Restart-WebAppPool  1.0.0.0 WebAdministration
        Cmdlet      Start-WebAppPool    1.0.0.0 WebAdministration
        Cmdlet      Stop-WebAppPool     1.0.0.0 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