Exchange Log File Monitoring Orchestration

Posted: December 6, 2012 in Orchestrator
Tags: , , , , ,

So what started this is actually quite simple. We have limited space on our virtual machines and the log files for IIS keeping filling up the drive on our Hub Transport Server (Exchange Server 2010). It is a little know fact, that a certain amount of free space on C: is needed on an Exchange Hub Transport Server, the magic number happens to be 15%. There are a few ways to solve the log file issue. I found this solution. This deletes all files older than 7 days. This can, of course, be modified to suit your needs, I personally have chosen 14 days. Some people choose more, it is basically a case of whatever works best for.

I could simple set this a scheduled task and allow this to run every few days and keep the log files to a reasonable size. However, I have orchestrator and was thinking that this would be a great chance to get my hands dirty and start to show the benefit of Orchestrator to some of the staff in our IT department. I know those that know Orchestrator, are saying “you have to convince them how good Orchestrator is?” and the answer is a resounding “YES”. Anyways, back onto topic here. Below is a diagram of the orchestration. I will go into more detail around my thinking for each step. Hopefully someone can learn from this and help drive the value of System Centre Orchestrator Smile


So, the first bit is simply a monitor allowing you specify how often you would like the Runbook to Run.



Next up, is a simple “Disk Space” monitor found under “Monitoring”


I have configured the parameters as needed.


I also tweaked the security parameters as needed to an account that has the required rights for checking Drive Space on the required server.


For the next step, I modified the “Link Properties” to match my needs of checking of the Disk Space to return a value that will allow the rest of the Runbook to run. It is simply a case of Clicking “Add” and then selecting the required values to check for. I chose “Percentage of Space Available” from Component Before “is less than” Desired percentage.


This is why I chose to create a runbook, my staff and Company like to be informed of any changes made on servers. So now I send an e-mail stating that the free space is low to the necessary recipients.


Now, I create a folder to allow for creation of text files for the logging of which files will be deleted. (more on this later)


I also use published data from earlier in the Databus to create unique folders based on date and time.


Now, I create a list of all the files to be deleted and read them into a “log file” and place them in the folder created above for “Auditing” purposes. I had to run this through a PowerShell script and there are some limitations with Orchestrator and Impersonating another account within PowerShell. I will continue to work on this to clean it up.

Please note that *subscribeddata* means data from earlier up the Databus, namely folder locations.


I run the below PowerShell script.

This reads the files to be deleted, older than 14 days, creates a log file, and reads the log file into the body of the e-mail.

net use H: *subsribeddata* /user:europcar\administrator &lt;password&gt;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; $files=get-childitem -Path \\ms-ec-exc01\C$\inetpub\logs\LogFiles -recurse | where-object {$_.lastwritetime -lt (get-date).addDays(-14)}| out-file -filepath "H:\logs.txt" -append<br>$body = (get-content *subscribeddata&gt;*logs.txt -encoding ASCII | out-string)<br>send-mailmessage -attachments &lt;subscribed data&gt;\logs.txt -body $body -to "" -from "" -subject "Files to be deleted" -smtpserver<br>net use h: /delete

Now it is time to delete the actual files


net use H: *subsribeddata* /user:europcar\administrator *password*&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; $files=get-childitem -Path \\ms-ec-exc01\C$\inetpub\logs\LogFiles -recurse | where-object {$_.lastwritetime -lt (get-date).addDays(-14)}| remove-item –recurse<br>net use h: /delete

Now it is time to check the Disk Space is at an adequate level.


Modify the link Properties again to meet new requirements. So, I have tweaked the script to ensure that the free space is now above my threshold ( I have set mine to 15%)



And then finally send an e-mail stating that the free space is now adequate. Tweaked to meet my needs with Subscribed data in the body and subject.


Please note that this information is provided as is. I can assist as much as possible. Please TEST, TEST and TEST again.

Hope this helps,

Follow me.




Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s