Sunday, February 19, 2012

Exchange Web Services Managed API 1.2 Released

As discussed in my previous post EWS Managed API 1.2 SDK Documentation Available, the EWS Managed API v1.2 is now available for download here.

You can check all the new features in the What’s New website, but for me best additions/improvements are:

For more information:

Tuesday, February 14, 2012

Microsoft Outlook Configuration Analyzer Tool


Microsoft just released the Outlook Configuration Analyzer Tool (OCAT ), which provides a quick and easy method to analyze your Outlook profile for common configurations that may cause problems.

This first version of OCAT allows you to do the following:
  • Scan your computer;
  • Open a previously run scan on your computer;
  • Import a scan from another computer;
  • Use several reporting formats to view the scan results ;
  • Start the Exchange Remote Connectivity Analyzer tool;
  • Send feedback to the OCAT team.

System requirements
Before you install OCAT, make sure that your computer meets the following system requirements.
Supported operating systems:
  • Windows 7
  • Windows Vista Service Pack 2
  • Windows XP Service Pack 3

This download works with the following Microsoft Office programs:
  • Microsoft Office Outlook 2007
  • Microsoft Outlook 2010 (32-bit or 64-bit)

You also need (minimum version) Microsoft .NET Framework Version 2.0
Be aware that you must make sure that Outlook is running before you start an OCAT scan!

The document that comes with the download covers really well everything that there is to know with this tool, so I will just post here some examples of what I got when I ran it on my Outlook profile.

Just like ExTRA and ExBPA, there are 3 report types: List Reports, Tree Reports and Other Reports.

When in List Reports, you have an “easy to read” view of Informational Issues, All Issues and Critical Issues:




Tree Reports gives you a more detailed a technical view:


Like I said, OCAT’s manual covers these in great detail, so I just wanted to put here a few example so you know what to expect.

DOWNLOAD: you can find OCAT here.

Monday, February 13, 2012

Exchange Server 2010 SP2 Help

The latest version of the Exchange 2010 help file has been released. This version (related to SP2) is from 31st of January 2012 and can be found here.

Wednesday, February 8, 2012

Infinite Loop of Nested Folders


A few weeks ago one user moved a subfolder of her Inbox into another subfolder beneath that one, which triggered the creation of an “infinite” loop of nested subfolders:


I tried to recreate this behaviour but every time I would get the following error (as one would expect):


So I am still not sure how all this happened... Anyway, time to delete those folders! And this is where it got interesting... First thing I tried was obviously to give myself FullAccess permissions to the mailbox and delete the folders myself. However, Outlook returned the following error:


4,000?! Humm... Let’s see how many items are in these folders and how many folders in total. To do this, I used the following two cmdlets (most output removed for simplicity):

[PS] C:\> Get-MailboxFolderStatistics “user” | ? {$_.FolderPath -eq "/Inbox/Pictures of Y"}
Name                              : Pictures of Y
FolderPath                        : /Inbox/Pictures of Y
FolderType                        : User Created
ItemsInFolder                     : 0
DeletedItemsInFolder              : 0
FolderSize                        : 0 B (0 bytes)
ItemsInFolderAndSubfolders        : 0
DeletedItemsInFolderAndSubfolders : 0
FolderAndSubfolderSize            : 0 B (0 bytes)

[PS] C:\> (Get-MailboxFolderStatistics “user”).Count
2922

Ok, so excluding all the default folders and the ones manually created by the user, there’s “only” around 2,890 folders with nothing on them. So why the error about the 4,000 limit?! Time to troubleshoot and get rid of these annoying folders!


Attempt 1
Although I had FullAccess permissions to the mailbox, decided to use ExFolders to grant myself Owner permissions on the top folder and all the subfolders. After almost 1h of propagating the permissions throughout all folders, still got the same error when trying to delete them using Outlook...

Noticed that after trying to delete the folders in Outlook, I would get the following error in the Application log of the Mailbox server (using my account to access the user’s mailbox):
Mapi session "a7198e9f-265f-4e94-b63d-7ee3d78c00c3: /o=domain/ou=exchange administrative group (fydibohf23spdlt)/cn=recipients/cn=motan" exceeded the maximum of 500 objects of type "objtFolder".


Attempt 2
Tried to delete the folders using OWA but a similar result...


Attempt 3
Tried exporting the mailbox to a PST file but it wouldn’t export it because of the folders... The export reaches 100%, then it goes down to 5%, then up again, until it eventually fails.
Tried excluding the top folder from the export using the following cmdlet:

New-MailboxExportRequest "user" -FilePath “\\server\F$\PSTs\user.pst” -ExcludeFolders “#Inbox#/Pictures of Y”

But it still didn’t work. I am not sure if the ExcludeFolders parameter also excludes subfolders or not... Both failed with the following message:
Error: MapiExceptionPartialCompletion: Unable to copy to target. (hr=0x40680, ec=0)
Operation: ISourceFolder.CopyTo
OperationSide: Source
Primary (c0e7ee8d-6f43-430a-b11f-dfba42501ee6)
PropTags: [ContainerContents; FolderAssociatedContents; ContainerHierarchy; DisplayName; RulesTable; 1071710466]


Attempt 4
Tried deleting the folders with MFCMapi but got the following error:


Attempt 5
Tried using Microsoft Exchange Server Information Store Viewer (MDBVU32) but it didn’t work as well. I wasn’t getting any errors and could create and delete other folders, but not the ones I wanted to...

MDBVU32 works “a bit” like MFCMapi. You basically logon and open the Message Store you want to access and then look for the folder (or e-mail) you want to work on.

You then change the operation to DeleteFolder() and click on Call Function... Select the flags you want and then click OK.

In my case nothing would happen for these folders although it would work for any other folders/e-mails...


Attempt 6
Thought about creating another mailbox and simply copy everything across but this would have an impact on the user and the categories wouldn’t be moved, so out of the question for now...


Attempt 7
Changing the type of the folder using MFCMapi:
  • Start MFCMapi with Outlook not set to cached mode;
  •  Logon and display store table;
  • Open mailbox/Top of Information Store;
  •  For an email sub folder that you want to delete;
  • Change PR_CONTAINER_CLASS to IPF.IMAP from IPF.Note;
  • Click OK in the property pane.

 But still the same error when deleting both from MFCMapi and Outlook...


Attempt 8
Isinteg was out of the question as it would take days to run on the DB where the user is and would affect everyone on that DB. So tried moving the mailbox to another DB but it didn’t work... After more than 3h always in 5%, it finally failed with the error (some output removed for simplicity):

Alias                            : user
Status                           : Failed
StatusDetail                     : FailedMAPI
BadItemLimit                     : 5000
BadItemsEncountered              : 0
OverallDuration                  : 04:38:45
TotalFailedDuration              : 03:25:37
TotalQueuedDuration              : 00:00:03
TotalInProgressDuration          : 01:13:04
TotalTransientFailureDuration    : 00:31:19
TotalMailboxSize                 : 1.23 GB (1,320,399,499 bytes)
TotalMailboxItemCount            : 25749
BytesTransferred                 : 0 B (0 bytes)
ItemsTransferred                 : 0
PercentComplete                  : 5
FailureCode                      : -2147024882
FailureType                      : MapiExceptionNotEnoughMemory
FailureSide                      : Source
Message                          : Error: MapiExceptionNotEnoughMemory: Unable to synchronize manifest. (hr=0x8007000e,
                                    ec=1008)
                                   Diagnostic context:
                                       Lid: 55847   EMSMDBPOOL.EcPoolSessionDoRpc called [length=142]
                                       Lid: 43559   EMSMDBPOOL.EcPoolSessionDoRpc returned [ec=0x0][length=739][latency
                                   =46]
                                       Lid: 23226   --- ROP Parse Start ---
                                       Lid: 27962   ROP: ropOpenFolder [2]
                                       Lid: 27962   ROP: ropIncrCfg [112]
                                       Lid: 27962   ROP: ropUpldStStrmBegin [117]
                                       Lid: 27962   ROP: ropUpldStStrmEnd [119]
                                       Lid: 27962   ROP: ropUpldStStrmBegin [117]
                                       Lid: 27962   ROP: ropUpldStStrmEnd [119]
                                       Lid: 27962   ROP: ropUpldStStrmBegin [117]
                                       Lid: 27962   ROP: ropUpldStStrmEnd [119]
                                       Lid: 27962   ROP: ropUpldStStrmBegin [117]
                                       Lid: 27962   ROP: ropUpldStStrmEnd [119]
                                       Lid: 27962   ROP: ropFXSrcGetBufferEx [156]
                                       Lid: 17082   ROP Error: 0x3F0
                                       Lid: 23137
                                       Lid: 21921   StoreEc: 0x3F0
                                       Lid: 27962   ROP: ropExtendedError [250]
                                       Lid: 1494    ---- Remote Context Beg ----
                                       Lid: 1238    Remote Context Overflow
                                       Lid: 7155    StoreEc: 0x3F0
                                       Lid: 7155    StoreEc: 0x3F0
                                       Lid: 7155    StoreEc: 0x3F0
                                       Lid: 7155    StoreEc: 0x3F0
                                       Lid: 7155    StoreEc: 0x3F0
                                       Lid: 7155    StoreEc: 0x3F0
                                       Lid: 7155    StoreEc: 0x3F0
                                       Lid: 7155    StoreEc: 0x3F0
                                       Lid: 7155    StoreEc: 0x3F0
                                       Lid: 7155    StoreEc: 0x3F0
                                       Lid: 7155    StoreEc: 0x3F0
                                       Lid: 7155    StoreEc: 0x3F0
                                       Lid: 7155    StoreEc: 0x3F0
                                       Lid: 7155    StoreEc: 0x3F0
                                       Lid: 7155    StoreEc: 0x3F0
                                       Lid: 7155    StoreEc: 0x3F0
                                       Lid: 7155    StoreEc: 0x3F0
                                       Lid: 7155    StoreEc: 0x3F0
                                       Lid: 7155    StoreEc: 0x3F0
                                       Lid: 7155    StoreEc: 0x3F0
                                       Lid: 7155    StoreEc: 0x3F0
                                       Lid: 6131    StoreEc: 0x3F0
                                       Lid: 22184
                                       Lid: 24312   StoreEc: 0x3F0
                                       Lid: 22360
                                       Lid: 2238    StoreEc: 0x3F0
                                       Lid: 20888
                                       Lid: 24504   StoreEc: 0x3F0
                                       Lid: 24148   StoreEc: 0x3F0
                                       Lid: 23796
                                       Lid: 2478    StoreEc: 0x3F0
                                       Lid: 1750    ---- Remote Context End ----
                                       Lid: 26849
                                       Lid: 21817   ROP Failure: 0x3F0
                                       Lid: 32758
                                       Lid: 16586   StoreEc: 0x3F0
                                       Lid: 22518
                                       Lid: 28874   StoreEc: 0x3F0
                                       Lid: 29516
                                       Lid: 31820   StoreEc: 0x3F0
FailureTimestamp                 : 02/02/2012 10:27:38
FailureContext                   : --------
                                   Operation: ISourceMailbox.EnumerateHierarchyChanges
                                   OperationSide: Source
                                   Primary (c0e7ee8d-6f43-430a-b11f-dfba42501ee6)
                                   Catchup: True


Attempt 9
Already getting desperate, decided to temporarily increase the maximum number of objects that can be handled by Outlook clients by setting both objtfolder and objtfolderview to a value greater than 500 (KB842022 or Maximum open folder objects per logon has been changed).

WARNING: this affects everyone on the mailbox server you set this and it also needs an IS restart so be very careful!!!

As I have a few servers that only host passive DBs, decided to implement the change in one of those servers (I set the registry key value to 3000) and switched over only that DB to that server.
Tried deleting the folders but was getting the same error regarding the 4,000 limit! Not sure why this time... Increased the registry key’s value to 6000 and decided to try again. However, although there were no errors at all on the server, no one could access any mailbox in that server!... Ups! Time to quickly rollback!
Another failed attempt...


Resolution
So how did I fix this problem? Since the beginning that I was thinking about what would happen if I tried to delete the last folder? Because I didn’t feel like expanding almost 3,000 folders (probably for Outlook to complain about the 500 limit!) this had to be done using a script.

Although I love writing scripts, I was avoiding doing this for some reason. But since everything else was failing, I decided to give it a go. And the result was that it worked without any problems!   :-D

I just wanted to quickly try this, so didn’t pay much attention to performance. For this reason, the script is not very efficient because:
it goes through all the folders one by one and then deletes the last one;
starts all over again, goes through all the folders one by one and then deletes the last one;
starts all over again....

In this case it took between 30 to 60 minutes to delete 2,890 folders but it eventually got there!   :)


WARNING: as with every script, make sure you test it properly before running it for a live user!!!


You can also find the script in the Microsoft TechNet Script Repository: Delete Outlook Folders Bottom-Up

# Script: DeleteFoldersBackwards.ps1
# Purpose: This scripts deletes every folder and subfolders for a specific top-folder starting from the last one
# Author: Nuno Mota
# Date:  Feb 2012

[String] $mbxName = "motan@parliament.uk"
[Int] $intCount = 0

[String] $dllPath = "E:\Program Files\Microsoft\Exchange\Web Services\1.1\Microsoft.Exchange.WebServices.dll"
[Void] [Reflection.Assembly]::LoadFile($dllPath)

$Service = New-Object Microsoft.Exchange.WebServices.Data.ExchangeService([Microsoft.Exchange.WebServices.Data.ExchangeVersion]::Exchange2010_SP1)
$Service.AutodiscoverUrl($mbxName, {$True})

# This is the root folder from where we want to start searching for the folder we want to delete.
# Once we find it, then we will go recursively down that folder.
# Other option would be to get the FolderID and start the search straight from there
$RootFolderID = new-object Microsoft.Exchange.WebServices.Data.FolderId([Microsoft.Exchange.WebServices.Data.WellKnownFolderName]::Inbox, $mbxName)
#$RootFolderID = new-object Microsoft.Exchange.WebServices.Data.FolderId([Microsoft.Exchange.WebServices.Data.WellKnownFolderName]::Root, $mbxName)
$RootFolder = [Microsoft.Exchange.WebServices.Data.Folder]::Bind($Service, $RootFolderID)

$FolderView = New-Object Microsoft.Exchange.WebServices.Data.FolderView(1000)
$FolderView.Traversal = [Microsoft.Exchange.WebServices.Data.FolderTraversal]::Deep
$Response = $RootFolder.FindFolders($FolderView)

# Go through all folders under the Inbox folder looking for the folder we want to delete
ForEach ($folder in $Response.Folders)
{
 # Check if the current folder is the folder we want to delete
 If ($folder.DisplayName -eq "Pictures of Y")
 {
  # Found the folder, so start a new Deep search across all its sub-folders
  $FolderView = New-Object Microsoft.Exchange.WebServices.Data.FolderView(3000)
  $FolderView.Traversal = [Microsoft.Exchange.WebServices.Data.FolderTraversal]::Deep
  $Response = $folder.FindFolders($FolderView)
  $RootFolder = $folder
  
  # Loop to go through all sub-folders while there are any
  While ($($Response.Folders).Count -gt 0)
  {
   # Get the last folder so we can then delete it (not very efficient...)
   ForEach ($folder in $Response.Folders)
   {
    #$folder.DisplayName
    $lastFolder = $folder
   }

   Write-Host "Deleting", $lastFolder.DisplayName
   $lastFolder.Delete([Microsoft.Exchange.WebServices.Data.DeleteMode]::HardDelete)
   $intCount++
   Write-Progress -Activity "Deleting Folders" -Status "Folders Deleted: $intCount"

   $Response = $RootFolder.FindFolders($FolderView)
  }

  # Delete the top folder and exit the first ForEach
  #Write-Host "Deleting Top ""$($RootFolder.DisplayName)"""
  $RootFolder.Delete([Microsoft.Exchange.WebServices.Data.DeleteMode]::HardDelete)
  Break
 }
}

Friday, February 3, 2012

Exchange AD Schema Changes


We all know that with every Exchange Service Pack [SP] we have to run the usual setup /PrepareSchema (or setup /ps) in order to prepare the Active Directory Domain Services Schema for the newer version of Exchange. This is because every new SP introduces new attributes and modifies some existing classes and attributes in the Schema. But what exactly is added and/or changed?! To help answering this question, Microsoft made available the Exchange Server Active Directory Schema Changes Reference document.

The latest version of the document, from November 2011, includes changes made by:
  • Exchange Server 2010 SP2, SP1 and RTM
  • Exchange Server 2007 SP3, SP2, SP1 and RTM
  • Exchange Server 2003

Not sure why the file is not available a “simple” download, but you have to download a nADSchemaRef.msi file, install it and then get the document from (by default) C:\Program Files\Microsoft\ExDevCenterDownloads\Exchange Server Active Directory Schema Changes Reference. Very strange...


Other alternative you have, is by looking at all the .ldf files that are used in the process, which are located in the \amd64\Setup\Data\ directory on the setup DVD.

I recon you will prefer the first method   :)