Exchange and iPhone Calendar Issues

March 3, 2011 by Bill Wade in IT Infrastructure


We have a couple of clients who contacted us recently and said some of their iPhone users – executives of course – were having calendar items disappear from their calendars. We researched the issue, but couldn’t find much solid information. Although several people have reported this problem, they are generally lumped together with iPhone users who are having overall sync problems. A resolution to this specific problem has not been identified.

Then one client told us that they heard from Microsoft that this is a known bug in both Exchange Server and in the iPhone. Apparently the bug has been fixed in Exchange Server 2010 SP1, and Apple has a fix for it in an upcoming release of IOS.

  • For Exchange 2010, install Exchange 2010 SP1
  • For Exchange 2007, install SP3 RU3

and

  • Get the Apple device iOS 4.3 beta 3. You have to contact Apple Support for availability.

We developed a workaround that seems to have solved the problem until Apple releases their update and it gets installed on people’s iPhones. We wrote a PowerShell script that identifies all users with iPhones and then we enabled the Calendar Repair Assistant to repair their calendars. The Calendar Repair Assistant goes through mailboxes and fixes inconsistencies. We found that in most cases it will replace missing meeting requests for users. The Calendar Repair Assistant is part of the Exchange Mailbox Assistants service; you can learn more about it at:

http://technet.microsoft.com/en-us/library/ee424432.aspx

During a defined time or duration, Calendar Repair Assistant will review calendar items for inconsistencies in mailboxes for which it is enabled. Here are the main steps I took and commands I used to work with the Calendar Repair Assistant:

Disable repair for all users on a mailbox server

I first used the following command to disable Calendar Repair ($true), because I only wanted to enable the service for users who I knew were experiencing problems:

get-mailbox -server <mailbox server> -resultsize Unlimited | Set-Mailbox -CalendarRepairDisabled $true

Enable repair for individual mailboxes

I then enabled Calendar Repair for individual users with the following command:Set-Mailbox -Identity <UPN> -CalendarRepairDisabled $false

Schedule for Mailbox Server

I then set the schedule to run for an hour every hour and let it run for 24 hours using the following command:

Set-MailboxServer -Identity admMBX2 -CalendarRepairWorkCycle 1.00:00:00 -CalendarRepairWorkCycleCheckpoint 1.00:00:00

Log location on Mailbox Server

Once the Calendar Repair Assistant starting doing its thing, I could see what it found by reviewing the log at the followinglocation:

C:\Program Files\Microsoft\Exchange Server\V14\Logging\Calendar Repair Assistant

View mailboxes with CalendarRepair enabled

Finally, if I wanted to review the users who have the assistant enabled, I could run the following command:

get-mailbox -server <mailbox server) -Filter “CalendarRepairDisabled -eq `$false” -ResultSize unlimited

This approach seemed to solve the problem for those users who had the Calendar Repair Assistant enabled. Occasionally, a user will see a meeting request in their calendar that was put there by the Calendar Repair Assistant as part of the repair. There is a large notice at the bottom of the calendar item that it was put there by the Calendar Repair Assistant.

However, users who did not have the Calendar Repair Assistant enabled would continue to experience problems. This meant we had to add users now and again to the list of enabled mailboxes.

To get around this issue until a fix is released and deployed for the iPhone, my favorite developer Ed Brovick borrowed a script written by Jan Egil Ring from here that identifies all iPhones on an Exchange mailbox server. Ed then added code to the script that pipes the results through the cmdlet that turns the Calendar Repair Assistant on for those mailboxes with iPhones. The final script looks like this:

#

#

# NAME: Get-ActiveSyncDeviceInfo.ps1

#

}

# AUTHOR: Jan Egil Ring

# EMAIL: jan.egil.ring@powershell.no

#

# COMMENT: Script to retrieve all ActiveSync-devices registered within the Exchange-organization.

#          A conversion-table for Apple-devices are provided, you might remove this if you want to

#          retrieve the real DeviceUserAgent-names for those devices.

#          The script outputs objects to make it easier working with the results, i.e. to export

#          the output using Export-Csv, sort them, group them and so on.

#          Works with both Exchange 2007 and Exchange 2010. Since a new cmdlet, Get-ActiveSyncDevice,

#          exist in Exchange 2010, you might want to use that when working against Exchange 2010.

#         

#          For more information, see the following blog-post:

#          http://blog.powershell.no/2010/09/26/getting-an-overview-of-all-activesync-devices-in-the-exchange-organization

#     

# You have a royalty-free right to use, modify, reproduce, and

# distribute this script file in any way you find useful, provided that

# you agree that the creator, owner above has no warranty, obligations,

# or liability for such use.

#

# VERSION HISTORY:

# 1.0 26.09.2010 – Initial release

#

#

#Retrieve all mailboxes in the Exchange organization

$mailboxes = Get-Mailbox -ResultSize unlimited

$mailbox

#Loop through each mailbox

foreach ($mailbox in $mailboxes) {

$devices = Get-ActiveSyncDeviceStatistics -Mailbox $mailbox.samaccountname | Select-Object DeviceType,DevicePolicyApplied,LastSuccessSync,DeviceUserAgent

#If the current mailbox has an ActiveSync device associated, loop through each device

if ($devices) {

foreach ($device in $devices){

#Conversion table for Apple-devices

switch ($device.DeviceUserAgent) {

“Apple-iPhone/701.341″ {$DeviceUserAgent = “iPhone”}

“Apple-iPhone/703.144″ {$DeviceUserAgent = “iPhone”}

“Apple-iPad/702.367″ {$DeviceUserAgent = “iPad”}

“Apple-iPod2C1/801.293″ {$DeviceUserAgent = “iPod”}

“Apple-iPod3C1/801.293″ {$DeviceUserAgent = “iPod”}

“Apple-iPhone1C2/801.293″ {$DeviceUserAgent = “iPhone 3G”}

“Apple-iPhone2C1/801.293″ {$DeviceUserAgent = “iPhone 3GS”}

“Apple-iPhone3C1/801.293″ {$DeviceUserAgent = “iPhone 4″}

“Apple-iPhone/508.11″ {$DeviceUserAgent = “iPhone”}

“Apple-iPhone/701.400″ {$DeviceUserAgent = “iPhone”}

“Apple-iPhone/704.11″ {$DeviceUserAgent = “iPhone”}

“Apple-iPhone/705.18″ {$DeviceUserAgent = “iPhone”}

“Apple-iPod2C1/801.306″ {$DeviceUserAgent = “iPod”}

“Apple-iPod3C1/801.306″ {$DeviceUserAgent = “iPod”}

“Apple-iPhone1C2/801.306″ {$DeviceUserAgent = “iPhone 3G”}

“Apple-iPhone2C1/801.306″ {$DeviceUserAgent = “iPhone 3GS”}

“Apple-iPhone2C1/801.400″ {$DeviceUserAgent = “iPhone 3GS”}

“Apple-iPhone3C1/801.306″ {$DeviceUserAgent = “iPhone 4″}

default {$DeviceUserAgent = $device.DeviceUserAgent}

}

#Create a new object and add custom note properties for each device

$deviceobj = New-Object -TypeName psobject

$deviceobj | Add-Member -Name User -Value $mailbox.samaccountname -MemberType NoteProperty

$deviceobj | Add-Member -Name DeviceType -Value $device.DeviceType -MemberType NoteProperty

$deviceobj | Add-Member -Name DeviceUserAgent -Value $DeviceUserAgent -MemberType NoteProperty

$deviceobj | Add-Member -Name DevicePolicyApplied -Value $device.DevicePolicyApplied -MemberType NoteProperty

#$deviceobj | Add-Member -Name LastSuccessSync -Value ($device.LastSuccessSync).ToShortDateString() -MemberType NoteProperty

#Write the custom object to the pipeline

#Write-Output -InputObject $deviceobj

if ($deviceobj.DeviceUserAgent -eq “iPhone”) {

            $D = “Set-Mailbox -Identity ” + $deviceobj.user + ” -CalendarRepairDisabled 0″

$D

#          write-Output -Inputobject $deviceobj.user

invoke-expression $D

#$deviceobj.user       

}

}

}

The result is that all users with iPhones on the mailbox server have the Calendar Repair Assistant enabled, which should prevent calendar items from disappearing and causing problems for those users.

To see which users had the Calendar Repair Assistant enabled by the script, run this command again:

get-mailbox -server <mailbox server) -Filter “CalendarRepairDisabled -eq `$false” -ResultSize unlimited

After a permanent fix is found, I recommend disabling the Calendar Assistant for all users with the following command:

get-mailbox -server <mailbox server> -resultsize Unlimited | Set-Mailbox -CalendarRepairDisabled $true

This bug affects users with iPhones who have many calendar items that are changing and large mailboxes – the exact profile of most corporate executives. So putting this solution in place until the patch is available may keep your boss on schedule and increase the score of your next annual review.