Code snippets : Restart IIS Application Pool in PowerShell


If you need to watch IIS application pool and start it once goes down and want to use PowerShell for that here is simple script for that.

Script includes also logging all restarts in log file which is created in same folder as script.

# AppPool to monitor
$AppPoolName = "AppPoolName"

# Log Destination
$LogToScreen = 1
$LogToFile = 1

# Determine script location for PowerShell
$ScriptDir = Split-Path $script:MyInvocation.MyCommand.Path

# Output log
$OutputLogPath = $ScriptDir + "\AppPoolRestart.csv"

#Check if file exists and create if it doesn't
If(!(Test-Path -Path $OutputLogPath)){
#Create file and start logging
New-Item -Path $OutputLogPath -ItemType File

# Function: LogMessage
function LogMessage($Msg, $ToScreen, $ToFile)
if ($ToScreen -eq 1)
Write-Host $Message

If ($ToFile -eq 1)
Add-Content -Path $OutputLogPath -Value $Message
# End Function: LogMessage

While (1 -eq 1){


$AppPoolStatus = Get-WebAppPoolState -Name $AppPoolName

$DateTime = Get-Date

If ($AppPoolStatus.Value -eq "Stopped"){
Write-Host "Not Working"
Start-WebAppPool -Name $AppPoolName
$Message = "App Pool $AppPoolName restarted at $DateTime"
LogMessage $Message $LogToScreen $LogToFile
Write-Host "Working"

Sleep 5

How-to : Adding SNMP to Windows Server 2008 R2


As a part of preparation for monitoring our WIndows Server 2008 R2 using SNMP and Nagios we had to add SNMP Services to few systems which didn’t have it yet. So, based on that fact I thought it might be nice to capture all steps involved in adding SNMP to Windows Server machine. Here you can see steps, screenshots and short description how to achieve that.



Config snippets : Cisco : Redirect console output to telnet session


This is one of those things I always forget when is needed. How to redirect console output to telnet session when debugging something on Cisco device.

So, not to forget it I record it for future reference (I guess from now on I will remember that, but well.. what you do… just Murphy’s law)

From telnet session just issue command shown below, and all debug logs will be redirected to telnet session.

R1#terminal monitor

How-to : Using WebSVN as RANCID repository access tool


In previous articles in the RANCID series I described:

So, we have RANCID collecting configuration from network devices to repository with version control. Only question is how to get access and make use of information collected there.

In this part of RANCID stories I will show how to install and configure WebSVN to access RANCID repository via web browser.



How-to : Adding devices to RANCID


Some time ago I described How to : Install RANCID on openSUSE 11.4 “Celadon”. However, just after installation RANCID will do nothing without proper configuration.

So, in this lab I will show how to:

  • create group of devices in rancid
  • add information about credentals to RANCID
  • add 2 Cisco routers to that group
  • collect configuration from routers
  • setup cron task to run rancid automatically

Systems which will be used to demonstrate how to add device to RANCID and collect configuration:

  • lab-gw-01 – IP: – openSUSE witn RANCID – installed on VMware Workstation
  • lab-r1 – IP: – Cisco router – started on GNS3
  • lab-r2 – IP: – Cisco router – started on GNS3



Config snippets : Cisco : Resetting interface statistics on Catalyst


Recently I went through troubleshooting of Site-to-Site Layer-2 link. One of the things we did during troubleshooting of that link was checking interface statistics for interfaces which were connecting two geographical sites together.

Below quick overview how ot check and reset port statistics if required during troubleshooting process.


Page 1 of 212