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 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{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 = ""

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,
public datefrom
public dateto
datefrom = "2006-03-26T10:00:00Z"
dateto = "2006-04-02T10:00:00Z"
domainname = ""
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 & """{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
While oRecSet.EOF <> True
select case oRecSet.fields("{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")
susapt = 1
upto = "(GMT+09:30) Adelaide (Commonwealth Games)"
end if
if instr(oRecSet.fields("urn:schemas:calendar:timezone").value,"TZID:GMT +1000")
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("{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
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("{00062002-0000-0000-C000-000000000046}/0x8234").value,vbcrlf,""),",","")
& "," & oRecSet.fields("urn:schemas:calendar:timezoneid").value)
set apptobj = createobject("ADODB.Record") 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 =
if upto <> "" then apptobj.Fields("{00062002-0000-0000-C000-000000000046}/0x8234").value
= upto
uptoid = ""
upto = ""
end if
susapt = 0
Set oRecSet = Nothing
Set oConn = Nothing
End Sub

Popular posts from this blog

Testing and Sending email via SMTP using Opportunistic TLS and oAuth in Office365 with PowerShell

As well as EWS and Remote PowerShell (RPS) other mail protocols POP3, IMAP and SMTP have had OAuth authentication enabled in Exchange Online (Official announcement here ). A while ago I created  this script that used Opportunistic TLS to perform a Telnet style test against a SMTP server using SMTP AUTH. Now that oAuth authentication has been enabled in office365 I've updated this script to be able to use oAuth instead of SMTP Auth to test against Office365. I've also included a function to actually send a Message. Token Acquisition  To Send a Mail using oAuth you first need to get an Access token from Azure AD there are plenty of ways of doing this in PowerShell. You could use a library like MSAL or ADAL (just google your favoured method) or use a library less approach which I've included with this script . Whatever way you do this you need to make sure that your application registration

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 .  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

The MailboxConcurrency limit and using Batching in the Microsoft Graph API

If your getting an error such as Application is over its MailboxConcurrency limit while using the Microsoft Graph API this post may help you understand why. Background   The Mailbox  concurrency limit when your using the Graph API is 4 as per . This is evaluated for each app ID and mailbox combination so this means you can have different apps running under the same credentials and the poor behavior of one won't cause the other to be throttled. If you compared that to EWS you could have up to 27 concurrent connections but they are shared across all apps on a first come first served basis. Batching Batching in the Graph API is a way of combining multiple requests into a single HTTP request. Batching in the Exchange Mail API's EWS and MAPI has been around for a long time and its common, for email Apps to process large numbers of smaller items for a variety of reasons.  Batching in the Graph is limited to a m
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.