IIS Log Setting and Log-Rolling

I needed to enable IIS logging on a batch of server and keep the log for 3 days. With PowerShell it’s an easy task, you just need the right command.

First, you need to import the Web Administration module to PowerShell (Used Run As an Administrator)

Import-Module WebAdministration

Then, to enable the Logging in IIS for a Web Site you enter

Set-ItemProperty "IIS:SitesDefault Web Site" -Name logfile.enabled -value $True

To set the Log Path to D:Logs

Set-ItemProperty "IIS:SitesDefault Web Site" -Name logfile.directory -value "D:Logs"

To set the Log File creation rolling (see the different value below)

Set-ItemProperty "IIS:SitesDefault Web Site" -Name logfile.period -value "4"

0 = MaxSized
1 = Daily
2 = Weekly
3 = Monthly
4 = Hourly

Continue reading IIS Log Setting and Log-Rolling

Exchange 2013 and AdminDisplayVersion

I have made a post in February about AdminDisplayVersion and how to use it to script multiversion script for Exchange (See it here), the problem is, it not working anymore with Exchange 2013 since they change the variable type from Version to String.

Exchange 2010

Exchange 2013

So, until this bug is resolve you can simply use something like this before the other if block

$version = Get-ExchangeServer | select -First 1 Admindisplayversion
$version = $version.AdminDisplayVersion.Major
if($Version -eq $NULL){
	$version = Get-ExchangeServer | select -First 1 Admindisplayversion
	[version]$TempVersion = $version.AdminDisplayVersion.tostring().split("VersionBuld() ")[8] +"."+$version.AdminDisplayVersion.tostring().split("VersionBuld() ")[16]
	$version = $Tempversion.Major

OAB Corruption

MBX sometime failed to update their OAB and even if you try to move them to another MBX the problem persist.
When that happen this Event Id is written in the Event Log of the MBX and the OAB doesn’t update anymore

Source : MSExchangeSA Event ID:9408 Content : OABGen failed to load the OAB version 4 manifest file ‘\MBXExchangeOABXXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXXoab.xml’. This may indicate data tampering or disk problems. Restore files in this folder from the recent backup or clean up folder content and force a full OAB generation.
– Name of the OAB

To resolve this issue you have 2 way as told by the event, this script take option 2 since I don’t backup file that can be recreated by a service.
It may work on Exchange 2007, but I have only test it on Exchange 2010. I run it as a schedule task.

Continue reading OAB Corruption

Repair Mailbox for a batch of Databases

I have got some trouble with the Search Indexer service on a server. Some Msftefd.exe process were taking all the available CPU. While digging to find the cause we move some DB to another server in the DAG and the problem move to that server, so I was sure that was not a local issue. The first thing I tough was mailbox item corruption that stuck the indexer. I got 2 choices repair the faulty mailbox or move it. Since I didn’t have time to lookup which mailbox was causing the issue and moving all those mailbox wasn’t an option (around 10 DBs were moved), I launch batch mailbox repair request. To calm down the service I have disabled the Indexing of those DB.

Since Exchange 2010 SP1 just take one Database at a time when we do New-MailboxRepairRequest, I just made this script to wait for me before continuing with the next database. Could be useful if you can’t figure out which Databases have that corrupted mailbox on the server or you just have many DB to scan.

Continue reading Repair Mailbox for a batch of Databases

How to script Service Pack and/or Rollup Installation

This is a script I have made to go faster in the Exchange SP2 deployment including the RU1 installation.

The SP part was pretty strait forward but I couldn’t find the RU command line installation to make automatic. I just had to pick the command from MSIEXE and put it into place. This way it install without prompting anything and then reboot.

Then I have made a menu to select which Rollup Update you want to install.

To see the part of this script just continue reading

Continue reading How to script Service Pack and/or Rollup Installation

Schedule a Powershell script

If you need to schedule a Exchange Script in the schedule task it may be a pain the first time so here the recipe :

Exchange 2013

Program/script :


Add arguments (optional) :

-command “. ‘C:Program FilesMicrosoftExchange ServerV15binRemoteExchange.ps1’; Connect-ExchangeServer -auto  -ClientApplication:ManagementShell; . ‘\SERVERNAMEScripts$EX-Script-Name.ps1’ -Param Detail -confirm”

Exchange 2010

Program/script :


Add arguments (optional) :

-command “. ‘C:Program FilesMicrosoftExchange ServerV14binRemoteExchange.ps1’; Connect-ExchangeServer -auto; . ‘\SERVERNAMEScripts$EX-Script-Name.ps1’ -Param Detail -confirm”


Exchange 2007

Program/script :


Add arguments (optional) :

-PSConsoleFile “C:Program FilesMicrosoftExchange Serverbinexshell.psc1” -command “. ‘C:Program FilesMicrosoftExchange ServerbinExchange.ps1’; . ‘c:scriptsSCRIPTNAME.ps1’ -Param Detail”


And don’t forget to enable your task scheduler user to run all script that are not sign with this Powershell command while logged in as the User

Set-ExecutionPolicy Bypass -scope CurrentUser


Set variable by Exchange version

Working for a Hoster pushed me do scripts for multiple environments at the same time. Since I don’t like to do double the work, I create scripts for all my environments to minimize the update time of a script. I use this function in my scripts to check on which environment it runs. Simple but very useful.

Continue reading Set variable by Exchange version

This is my blog and it's all about MS Exchange