Tuesday, June 22, 2010

Logging of IIS AppPools status for remote servers (Win 2003) using PowerShell


I was having a struggle in writing a script which would log the status of the App Pool from across all the remote servers. I tried using two things -

2> Get-WMIObject

Using the ADSI, I faced issue in which it was not able to access the remote server. It used to say RPC server unavailable. But the same when I tried using Get-WMIObject, it was able to get data from remote server. The catch here was, the Children class was availabe from ADSI but the same was not found using Get-WMIObject . Finally I was able to write the script using the Get-WMIObject.



[string]$global:computer = $env:COMPUTERNAME

,[string]$LogDir = "d:\AppPoolLogging"


,[switch]$enableLogging = $true


function Convert-AppPoolState([int]$value){

switch ($value){

1 {"Starting"; break}

2 {"Started" ; break}

3 {"Stopping"; break}

4 {"Stopped" ; break}

default {"Unknown"}



Function Write-Log($appPoolName,$message){

$dateTime = Get-Date -format "yyyyMMdd"

$LogFile = "$dateTime.log"

$logPath = join-path $LogDir $LogFile

$output = (Get-Date -Format "yyyyMMdd_HH:mm:ss") + "|" + $computer + "|" + $appPoolName + "|" + $message


If ($enableLogging) {$output | Out-File $logPath -Append}


Function Trim-AppPoolName ($appPoolName){

$computers = Get-Content "c:\computerlistall.txt"

foreach ($computer in $computers)


$iis = Get-WmiObject -Namespace root\MicrosoftIISv2 -Class IIsApplicationPoolSetting -ComputerName $computer -Authentication PacketPrivacy


$i = $iis.Count

for ($k = 0; $k -lt $i; $k++)

$name = $iis[$k].Name

$ApplicationPoolName = Trim-AppPoolName $name

$state = $iis[$k].AppPoolState

$Status = Convert-AppPoolState $state

Write-Log $ApplicationPoolName $Status



Monday, June 14, 2010

Installing the SMTP and POP 3 Services on Windows Server 2003

I know this would be real old stuff and many would be aware of these. But I would like to share it with respect to Sharepoint where we have to configure the incoming and outgoing mails. I would like to start from the beginning and provide other steps for configuring mails in sharepoint later. Hope you enjoy the post.

1> Click Start --> Control Panel --> Add or Remove Programs.
2> Click the Add/Remove Windows components button to the left of the Programs list. The Windows component wizard will appear.
3> Select Application Server and then click on the Details button below.
4> When the Application Server Dialogue box appears, Click Internet Information Services(IIS) to select it and then again click on the Details button below.
5> Tick the SMTP service check box and click OK. Then click OK again in the Application Server Dialogue box.
6> Click OK and in the Windows Component wizard dialogue box, tick the E-mail Services check box. Then click the Details button.
7> verify that both the POP 3 Service and POP 3 Service Web Administration is selected and ticked. Then Click OK.
8> In the Windows Components Wizard Dialogue box, click Next to install all the components.
9> If you have your windows 2003 CD, it will call the folder "i386" and then will install all the components. If you dont have the CD, you need to get a copy of that folder and then run the Component which shall install the components requested.