Exchange Time Zone Update Utility
Yep, I know, there's probably a nice PowerShell way to do this. But I was looking for quick and I know VB.NET pretty well. Threw this console app together to aggregate all of the MsExTmz utility logs into a nice XML (you can open it in Excel, etc). This parsed about 7000 logs in under 20 seconds (across 6 workstations running the msextmz utility).
Just change the info where you see folderPath.Add() to your list of machines/paths where msextmz logs reside.
Link for more info on the DST updates from Exchange Team blog.
Enjoy.
Imports System.IO
Module Module1
Enum FileSection As
Integer
Start = 1
OrigTz = 2
NewTz = 3
Log = 4
End
Enum
Sub Main()
' Spin up our datatable
Dim dt As
New DataTable("Parse Results")
' Table columns
With dt.Columns
.Add("File")
.Add("User")
.Add("OrigTZ")
.Add("NewTZ")
.Add("Type")
.Add("ID")
.Add("Subject")
.Add("OldStart")
.Add("NewStart")
.Add("OldEnd")
.Add("NewEnd")
.Add("Recur")
.Add("Result")
End
With
' Set Folder Path collection
Dim folderPath As
New Collections.ObjectModel.Collection(Of
String)
folderPath.Add("\\path1\c$\file directory")
folderPath.Add("\\path2\c$\file directory")
For
Each path As
String
In folderPath
' Get file list
Dim fileList As Collections.ObjectModel.ReadOnlyCollection(Of
String) = My.Computer.FileSystem.GetFiles(path, FileIO.SearchOption.SearchTopLevelOnly, "msextmz-*.log")
' Grab our file loop and lets get busy
For
Each fileName As
String
In fileList
' progress
Console.WriteLine(fileName)
' Get the common variables
Dim fileSplit As
String() = fileName.Split("-")
Dim user As
String = fileSplit(1)
' open the file for reading
Dim sr As
New StreamReader(fileName)
Dim sect As FileSection = FileSection.Start
Dim origTz, newTz As
String
' line reader loop
Do
While sr.Peek >= 0
Dim cl As
String = sr.ReadLine
' Is this a blank line?
If cl = ""
Then
Continue
Do
' where are we in the file?
If cl.StartsWith("[Original Time Zone") Then
' we're at the beginning, read the next line as orig tz and move on
sect = FileSection.OrigTz
Continue
Do
ElseIf cl.StartsWith("[New Time Zone]") Then
sect = FileSection.NewTz
Continue
Do
ElseIf cl.StartsWith("[Time Zone Update Log]") Then
sect = FileSection.Log
Continue
Do
End
If
' Now, depending on where we are in the file, let's start reading.
If sect = FileSection.OrigTz Then
origTz = cl
Continue
Do
ElseIf sect = FileSection.NewTz Then
newTz = cl
Continue
Do
End
If
' For the meat of the file, this requires some really fun looping
Dim dr As DataRow = dt.NewRow
dr.Item("File") = fileName
dr.Item("User") = user
dr.Item("OrigTZ") = origTz
dr.Item("NewTZ") = newTz
If sect = FileSection.Log Then
If cl.StartsWith("Type:") Then
' Save the type
dr.Item("Type") = cl.Remove(0, 6).ToString
' Move to the next line and figure out where we are, repeatedly. Exit on result.
Do
cl = sr.ReadLine
If cl.StartsWith("ID") Then
dr.Item("ID") = cl.Remove(0, 4).ToString
ElseIf cl.StartsWith("Subject") Then
dr.Item("Subject") = cl.Remove(0, 9).ToString
ElseIf cl.StartsWith("Old Start Time") Then
dr.Item("OldStart") = cl.Remove(0, 16).ToString
ElseIf cl.StartsWith("New Start Time") Then
dr.Item("NewStart") = cl.Remove(0, 16).ToString
ElseIf cl.StartsWith("Old End Time") Then
dr.Item("OldEnd") = cl.Remove(0, 14).ToString
ElseIf cl.StartsWith("New End Time") Then
dr.Item("NewEnd") = cl.Remove(0, 14).ToString
ElseIf cl.StartsWith("Recurring") Then
dr.Item("Recur") = cl.Remove(0, 11).ToString
ElseIf cl.StartsWith("Result") Then
dr.Item("Result") = cl.Remove(0, 8).ToString
Exit
Do
End
If
Loop
' into the datatable we go
dt.Rows.Add(dr)
End
If
End
If
Loop
Next
Next
' ok, all done. Let's export the datatable
dt.WriteXml("c:\exportTz.xml")
End
Sub
End
Module