A piece of my work around PowerShell and IIS (or usefull things I've found on the web). Mostly some reminders for myself!

Search a error pattern in the HTTP.SYS error log and recycles the application pool if finded

 

# Definition of the log file to search in
$LastLog = Get-ChildItem C:\WINDOWS\system32\LogFiles\HTTPERR | Sort -Property LastWriteTime | Select -Last 1
$File = "C:\WINDOWS\system32\LogFiles\HTTPERR\" + $LastLog
# Assuming the website ID is '1'
$Pattern = "503 1 AppOffline"
$Find = Select-String -Path $File -Pattern $Pattern -Quiet -SimpleMatch
# Recycling the ApplicationPool 'ASP.NET v4.0 32 bit' if the searched string has been found in the error log
if ($Find -eq $true) {Restart-WebAppPool "ASP.NET v4.0 32 bit"}

Name*Email*WebsiteComment

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.

Scroll to Top