Skip to main content

Updating appointments that are 1 hour out because of the Commonwealth Games Timezone Changes

Since i posted this last month I had a few questions around updating appointments that appear 1 hour out after you have updated the Timezone patch for the Commonwealth games. Firstly the only supported method of updating affected appointment is in http://www.microsoft.com/australia/timezone/2005.aspx which is to export the appointments in the overlap period to a text file, delete the appointments and then re-import those appointments.

One completely unsupported method to update appointments is to use CDOEX and Exoledb to move the appointment times one hour into the past for appointments that exists in the overlap period. One issue with using this method is that if you have any reoccurring appointments that have been expanded within the overlap period then changing the date and time on these instances of the recurring appointments will break the recursion on that instance of the expanded appointment so although outlook will show the appointment now occurs at the right time is will show the circle with the cross through it to indicate this appointment is an exception to the normal recurrence of the appointment. The other issue is that apart from myself this method hasn’t been really tested so there may be some other potential snags. But if you’re looking for something to test in a development environment to see if you can fix this problem this script could come in handy. The other problem is there has now been a patch released for home users that modifies the current timezone instead of adding a new time-zone. Its recommended that you don’t use this patch if you use Exchange or OWA and its quite possible that machines will have this patch applied and have created appointments that appear correct with the old timezone data. In this case running this script would actually make those appointments appear wrongly. You really need to be aware of how your machines have been patched before contemplating a fix.

The Script

Before you run the fix script I recommend you run a scan using another script I posted here. This will give you a list of all the appointments that are in the affected overlap period and which appointments will be modified by the script. The fix script queries for appointments within the overlap period that appear to be created from machines that haven’t had the patch applied or from OWA where the Timezone has been updated in the options. By looking at the urn:schemas:calendar:timezoneid property or the http://schemas.microsoft.com/mapi/id/{00062002-0000-0000-C000-000000000046}/0x8234 mapi property. The script then shifts the time of the appointment back one hour by adjusting the start and end times and updates the timezone information so that if the script is run again it wont modify the appointments for a second time.

Before using the script you need to update the domainname variable within the script to reflect the default SMTP domain name you are using eg

domainname = "domain.com"


The script uses Exoldb so it needs to be run from the server where the mailbox is located. The script is designed to be run on one mailbox at a time so to run the script you need to enter the mailbox you what to run it against as a commandline parameter eg cscript gapchangeex.vbs username. As stated before don’t run this script in production unless you have thoroughly tested it.

I’ve posted a copy of the script here the script itself looks like

user = wscript.arguments(0)
Set fso = CreateObject("Scripting.FileSystemObject")
fname = "c:\" & wscript.arguments(0) & ".csv"
set wfile = fso.opentextfile(fname,2,true)
wfile.writeline("User,Subject,UTC timestart,UTC timeend, InstanceType,
OutlookTimezone,CDOTimezoneEnumID")
public datefrom
public dateto
datefrom = "2006-03-26T10:00:00Z"
dateto = "2006-04-02T10:00:00Z"
domainname = "domain.com"
sConnString = "file://./backofficestorage/" & domainname
sConnString = sConnString & "/mbx/" & user & "/calendar"
call QueryCalendarFolder(sConnString,user)

wscript.echo "Done"


Public Sub QueryCalendarFolder(sConnString,user)
SSql = "SELECT ""DAV:href"", ""DAV:parentname"", ""urn:schemas:calendar:timezoneid"",
""urn:schemas:httpmail:subject"", "
SSql = SSql & """http://schemas.microsoft.com/mapi/id/{00062002-0000-0000-C000-000000000046}/0x8234"",
""urn:schemas:calendar:timezone"", "
SSql = SSql & """urn:schemas:calendar:instancetype"", ""urn:schemas:calendar:dtstart""
, ""urn:schemas:calendar:dtend"" "
SSql = SSql & "FROM scope('shallow traversal of """ & sConnString & """') "
SSql = SSql & " Where ""DAV:isfolder"" = false AND ""DAV:ishidden"" = false "

SSql = SSql & "AND ""urn:schemas:calendar:dtend"" > CAST(""" & datefrom & """ as
'dateTime') " _
& "AND ""urn:schemas:calendar:dtstart"" < CAST(""" & dateto & """ as 'dateTime')"

Set oConn = CreateObject("ADODB.Connection")
oConn.Provider = "Exoledb.DataSource"
oConn.Open sConnString
Set oRecSet = CreateObject("ADODB.Recordset")
oRecSet.CursorLocation = 3
oRecSet.Open sSQL, oConn.ConnectionString
if err.number <> 0 then wfile.writeline(user & "," & "Error Connection to
Mailbox")
While oRecSet.EOF <> True
select case oRecSet.fields("http://schemas.microsoft.com/mapi/id/{00062002-0000-0000-C000-000000000046}/0x8234").value
case "(GMT+10:00) Canberra, Melbourne, Sydney" susapt = 1
upto = "(GMT+10:00) Canberra, Melbourne, Sydney (Commonwealth Games)"
case "(GMT+09:30) Adelaide" susapt = 1
upto = "(GMT+09:30) Adelaide (Commonwealth Games)"
case "(GMT+10:00) Hobart" susapt = 1
upto = "(GMT+10:00) Hobart (Commonwealth Games)"
case "(GMT+10:00) Canberra, Melbourne, Sydney (Commonwealth Games)" susapt = 2
case "(GMT+09:30) Adelaide (Commonwealth Games)" susapt = 2
case "(GMT+10:00) Hobart (Commonwealth Games)" susapt = 2
end select
select case oRecSet.fields("urn:schemas:calendar:timezoneid").value
case "78" susapt = 2
case "79" susapt = 2
case "80" susapt = 2
case "57" susapt = 1
uptoid = "78"
case "19" susapt = 1
uptoid = "79"
case "42" susapt = 1
uptoid = "80"
end select
if susapt = 0 then
if instr(oRecSet.fields("urn:schemas:calendar:timezone").value,"TZID:GMT +0930")
then
susapt = 1
upto = "(GMT+09:30) Adelaide (Commonwealth Games)"
end if
if instr(oRecSet.fields("urn:schemas:calendar:timezone").value,"TZID:GMT +1000")
then
susapt = 1
upto = "(GMT+10:00) Canberra, Melbourne, Sydney (Commonwealth Games)"
end if

end if
if susapt = 1 then
Wscript.echo User
wscript.echo oRecSet.fields("DAV:Href").value
wscript.echo oRecSet.fields("urn:schemas:httpmail:subject").value
wscript.echo oRecSet.fields("http://schemas.microsoft.com/mapi/id/{00062002-0000-0000-C000-000000000046}/0x8234").value
wscript.echo oRecSet.fields("urn:schemas:calendar:timezoneid").value
wscript.echo oRecSet.fields("urn:schemas:calendar:instancetype").value
wscript.echo
wfile.writeline(user & "," &
oRecSet.fields("urn:schemas:httpmail:subject").value & ","_
& oRecSet.fields("urn:schemas:calendar:dtstart").value & "," &
oRecSet.fields("urn:schemas:calendar:dtend").value _
& "," & oRecSet.fields("urn:schemas:calendar:instancetype").value & "," _
& replace(replace(oRecSet.fields("http://schemas.microsoft.com/mapi/id/{00062002-0000-0000-C000-000000000046}/0x8234").value,vbcrlf,""),",","")
_
& "," & oRecSet.fields("urn:schemas:calendar:timezoneid").value)
set apptobj = createobject("ADODB.Record")
apptobj.open cstr(oRecSet.fields("DAV:HREF").value),,3
wscript.echo dateadd("h",-1,oRecSet.Fields("urn:schemas:calendar:dtstart").value)
apptobj.Fields("urn:schemas:calendar:dtstart").value = dateadd("h",-1,oRecSet.Fields("urn:schemas:calendar:dtstart").value)
apptobj.Fields("urn:schemas:calendar:dtend").value = dateadd("h",-1,oRecSet.Fields("urn:schemas:calendar:dtend").value)
if uptoid <> "" then apptobj.Fields("urn:schemas:calendar:timezoneid").value =
uptoid
if upto <> "" then apptobj.Fields("http://schemas.microsoft.com/mapi/id/{00062002-0000-0000-C000-000000000046}/0x8234").value
= upto
apptobj.Fields.update
apptobj.close
uptoid = ""
upto = ""
end if
susapt = 0
oRecSet.MoveNext
wend
oRecSet.Close
oConn.Close
Set oRecSet = Nothing
Set oConn = Nothing
End Sub

Popular posts from this blog

Using the MSAL (Microsoft Authentication Library) in EWS with Office365

Last July Microsoft announced here they would be disabling basic authentication in EWS on October 13 2020 which is now a little over a year away. Given the amount of time that has passed since the announcement any line of business applications or third party applications that you use that had been using Basic authentication should have been modified or upgraded to support using oAuth. If this isn't the case the time to take action is now. When you need to migrate a .NET app or script you have using EWS and basic Authentication you have two Authentication libraries you can choose from ADAL - Azure AD Authentication Library (uses the v1 Azure AD Endpoint) MSAL - Microsoft Authentication Library (uses the v2 Microsoft Identity Platform Endpoint) the most common library you will come across in use is the ADAL libraries because its been around the longest, has good support across a number of languages and allows complex authentications scenarios with support for SAML etc. The

How to test SMTP using Opportunistic TLS with Powershell and grab the public certificate a SMTP server is using

Most email services these day employ Opportunistic TLS when trying to send Messages which means that wherever possible the Messages will be encrypted rather then the plain text legacy of SMTP.  This method was defined in RFC 3207 "SMTP Service Extension for Secure SMTP over Transport Layer Security" and  there's a quite a good explanation of Opportunistic TLS on Wikipedia  https://en.wikipedia.org/wiki/Opportunistic_TLS .  This is used for both Server to Server (eg MTA to MTA) and Client to server (Eg a Message client like Outlook which acts as a MSA) the later being generally Authenticated. Basically it allows you to have a normal plain text SMTP conversation that is then upgraded to TLS using the STARTTLS verb. Not all servers will support this verb so if its not supported then a message is just sent as Plain text. TLS relies on PKI certificates and the administrative issue s that come around certificate management like expired certificates which is why I wrote th

A walk-though using the Graph API Mailbox reports in Powershell

Quite recently the Reporting side of the Graph API has moved in GA from beta, there are quite a number of reports that can be run across various Office365 surfaces but in this post I'm going to focus on the Mailbox related ones. Accessing Office365 Reports using Powershell is nothing new and has been available in the previous reporting endpoint  https://msdn.microsoft.com/en-us/library/office/jj984326.aspx however from the end of January many of these cmdlets are now being depreciated in favour of the Graph API  https://msdn.microsoft.com/en-us/library/office/dn387059.aspx . Prerequisites  In comparison to using the Remote PowerShell cmdlets where only the correct Office365 Admin permissions where needed, to use the new Graph API reports endpoint you need to use OAuth for authentication so this requires an Application Registration  https://developer.microsoft.com/en-us/graph/docs/concepts/auth_overview  that is then given the correct oAuth Grants to use the Reports EndPoin
All sample scripts and source code is provided by for illustrative purposes only. All examples are untested in different environments and therefore, I cannot guarantee or imply reliability, serviceability, or function of these programs.

All code contained herein is provided to you "AS IS" without any warranties of any kind. The implied warranties of non-infringement, merchantability and fitness for a particular purpose are expressly disclaimed.