Last active
July 30, 2018 00:28
-
-
Save peaeater/742e63a21b637a66f5ed to your computer and use it in GitHub Desktop.
Restarts named application pool if stopped, writes restart event to the Windows Application Event Log.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # restarts named app pool if stopped, writes restart event to the Application Event Log | |
| # Peter Tyrrell, May 13 2013 | |
| param( | |
| [string[]]$names = (,"ISAPI Webpublisher") | |
| ) | |
| # If OS < Server 2008 R2, install Powershell snap-in for IIS and uncomment: | |
| #Add-PSSnapin WebAdministration | |
| $evtsrc = "AppPool Resurrector" | |
| if ( [System.Diagnostics.EventLog]::SourceExists($evtsrc) -eq $false){ | |
| New-EventLog -LogName Application -Source $evtsrc | |
| } | |
| foreach ($name in $names) { | |
| if ((Get-WebAppPoolState $name).Value -ne "Started") { | |
| Start-WebAppPool $name | |
| Write-EventLog -LogName Application -Message "Started Application Pool `"$name`" because it was found stopped." -Source $evtsrc -EntryType Warning -EventId 666 -Category 0 | |
| echo "Started Application Pool `"$name`" because it was found stopped." | |
| } | |
| else { | |
| Write-EventLog -LogName Application -Message "Checked running state of `"$name`" app pool." -EntryType Information -EventId 0 -Category 0 -Source $evtsrc | |
| echo "Checked running state of `"$name`" app pool." | |
| } | |
| } | |
| <# | |
| App Pool Resurrector License | |
| Copyright © 2013 Peter Tyrrell and Andornot Inc. | |
| Permission is hereby granted, free of charge, | |
| to any person obtaining a copy of this software | |
| and associated documentation files (the “Software”), | |
| to deal in the Software without restriction, including | |
| without limitation the rights to use, copy, modify, | |
| merge, publish, distribute, sublicense, and/or | |
| sell copies of the Software, and to permit persons | |
| to whom the Software is furnished to do so, | |
| subject to the following conditions: | |
| The above copyright notice and this permission notice | |
| shall be included in all copies or substantial portions | |
| of the Software. | |
| THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY | |
| OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT | |
| LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | |
| FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. | |
| IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS | |
| BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, | |
| WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, | |
| ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE | |
| OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. | |
| #> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment