Fixing Well-Known Folders

This script fixes mailbox folder names, which might be required after importing PST files. This script will fix folder naming issues when you have the well-known folders in different language settings and possibly with number suffixes (e.g. Inbox1).

4.6 Star
3,327 times
Add to favorites
E-mail Twitter Digg Facebook
  • Czech language
    2 Posts | Last post April 17, 2017
    • Thanks for this script, still valid in 2017. Adding CZ translation.
              "cs-CZ"= @{ 
                  "Inbox"="Doručená pošta"; 
                  "SentItems"="Odeslaná pošta"; 
                  "DeletedItems"="Odstraněná pošta"; 
                  "Outbox"="Odchozí pošta"; 
                  "JunkEmail"="Nevyžádaná pošta"; 
                  "DateFormat"="d. M. yyyy"; 
    • Thanks!
  • Getting errors on script execution
    2 Posts | Last post February 28, 2016
    • New-Object : Multiple ambiguous overloads found for "ExchangeService" and the argument count: "1".
      At C:\Scripts\Fix-MailboxFolders2.ps1:514 char:22
      +         $EwsService= New-Object Microsoft.Exchange.WebServices.Data.ExchangeServ ...
      + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
          + CategoryInfo          : InvalidOperation: (:) [New-Object], MethodException
          + FullyQualifiedErrorId : ConstructorInvokedThrowException,Microsoft.PowerShell.Commands.NewObjectCommand
      The property 'UseDefaultCredentials' cannot be found on this object. Verify that the property exists and can be set.
      At C:\Scripts\Fix-MailboxFolders2.ps1:533 char:13
      +             $EwsService.UseDefaultCredentials= $true
      +             ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
          + CategoryInfo          : InvalidOperation: (:) [], RuntimeException
          + FullyQualifiedErrorId : PropertyNotFound
    • Downloading the file the right way resolved the errors. 
      Note to self: Don't download the file by right-clicking the link and choosing 'save link as...'
  • wrong place
    2 Posts | Last post September 19, 2014
    • hi,
      somehow ive got a user mailbox which has his rss and spam folder in the trash can... ive tried everything and couldnt fix it... any idea what i could do to fix it? exchange 2007
    • did it.
      2, Launch MFCMAPI tool on the user’s client. 
      3, Go to Session -> Logon and Display Store Table
      4, Select the outlook profile of the user and double-click “Mailbox - your user name”
      5, Expand "Root Container"
      6, Expand "IPM_subtree" 
      7, Locate Junk E-mail, right click it and select Copy
      8, Highlight IPM_subtree, right click it ans select Paste, click OK, check "COPY_SUBFOLDERS" and FOLDER_MOVE, click OK.
  • Is it possible to drop the destination language from the script?
    2 Posts | Last post August 20, 2014
    • First off, well done.
      When I searched for something similar 2 years ago I came across a script by Glen Scales on a technet forum post. I can't find it anymore but do have the script. (I was actually searching for the post again when I came across this).
      He searched for the destionation foldernames with this which might make the script even easier to use:
      $dllpath = "C:\Program Files\Microsoft\Exchange\Web Services\1.1\Microsoft.Exchange.WebServices.dll"
      $service = New-Object Microsoft.Exchange.WebServices.Data.ExchangeService([Microsoft.Exchange.WebServices.Data.ExchangeVersion]::Exchange2010)
      $windowsIdentity = [System.Security.Principal.WindowsIdentity]::GetCurrent()
      $sidbind = "LDAP://<SID=" + $windowsIdentity.user.Value.ToString() + ">"
      $aceuser = [ADSI]$sidbind
      $InboxFolderId = new-object Microsoft.Exchange.WebServices.Data.FolderId([Microsoft.Exchange.WebServices.Data.WellKnownFolderName]::Inbox,$MailboxName)
      $InboxFolder = [Microsoft.Exchange.WebServices.Data.Folder]::Bind($service,$InboxFolderId)
      "InboxFolder: "+$InboxFolder.Displayname
      This way, you only need to specify the source folder or language that should be migrated.
      Again well done,
    • 1) Depending on the migration strategy, the mailbox locale might not be set.
      2) When contents has been imported, it does not contain hints on the old 'locale'. They are just folders unless they match the desired locale, but then one could end up with sequential folders, Inbox1 etc. So, we need a way to specify the old set of names to use (i.e. move contents from).
  • Exchange 2007
    5 Posts | Last post August 15, 2014
    • Is this script also usable for Exchange 2007
    • Yes
    • im not able to make it work with 2007 Set-MailboxRegionalConfiguration is not supported on 2007
    • i have not been able to use on 2007 but for your information if you want to add french
              "fr-CA"= @{
                  "Inbox"="Boîte de réception"; 
                  "SentItems"="Éléments envoyés"; 
                  "DeletedItems"="Éléments supprimés"; 
                  "Outbox"="Boîte d'envoi"; 
                  "JunkEmail"="Courrier indésirables";
    • True, Set-MailboxRegionalConfiguration is to configure the mailbox locale and will adjust the well-known folder names (e.g. Inbox) to match a certain locale. I use it to match it with the required setting (Language) and use FromLanguage (or Get-MailboxRegionalConfiguration) to look up the names of lingering folders for which we need to move contents.
      Anyway, I'll put an 'Exchange2007' switch on the todo list. Thanks for your feedback.
  • Exchange 2013CU1
    4 Posts | Last post September 23, 2013
    • Hi,
      I am trying this on a Exchange 2013CU1. I have installed Microsoft Exchange Web Services Managed API 2.0. But when I run the script, I get:
      F:\Fix-MailboxFolders.ps1 : Problem loading EWS Managed API DLL
    • Will have look (tested w/1.2), I'll get back to you
    • I guess the cause of this error is incorrect path to Microsoft.Exchange.WebServices.dll. The path that the script gets is incorrect. If you change 372nd line to direct path to dll and comment 378th line you'll get a working solution. But I've tried EWS 1.2 on Exch 2013.
      And I have my own question:). Does this script rename Outlook folder with index to ones without it (Inbox1 to Inbox and etc.) As I understand it doesn't rename default Outlook folders and it only copies items to right place. But if default folder is with index it won't be changed. Am I right?
    • Q: Does this script rename Outlook folder with index to ones without it (Inbox1 to Inbox and etc.) As I understand it doesn't rename default Outlook folders and it only copies items to right place. But if default folder is with index it won't be changed. Am I right?
      A: After setting the Mailbox Regional Settings (which may rename the Well-Known folder) and specifying the from Language (since we can't guess) what folder names you'd like to merge, this may differ from current regional setting, eg after PST Import!) the current well-known folder will be Inbox, and contents of Inbox1..InboxN or localized index versions will be moved to Inbox, depending on FromLanguage or current regional setting (when FromLanguage not specified).
  • Exchange 2013
    3 Posts | Last post September 12, 2013
    • Hello,
      I can see that you have put great effort into this script. By using the comment on the CU1 post about updating the path on line 372/378 I got it starting. Anyway, I'm not getting very far. Errors below. I'm on Exchange 2013 CU2.
      The problem I'm trying to overcome is that a mailbox created with sv-SE language is now called "Inkorg" instead of "Inkorgen" and that seem to give me some trouble when importing PST-files.
      [PS] C:\Files\FolderScripts>.\Fix-MailboxFolders.ps1 -Mailbox test -Language sv-SE -FromLanguage en-US -verbose
      VERBOSE: Loading EWS Managed API DLL
      VERBOSE: Loading C:\Program Files\Microsoft\Exchange\Web Services\2.0\\Microsoft.Exchange.WebServices.dll
      Processing mailbox test
      VERBOSE: Set to trust all certificates
      VERBOSE: Looking up EWS URL using Autodiscover for
      VERBOSE: Using EWS on CAS
      VERBOSE: From language selected is en-US
      VERBOSE: Setting mailbox language to sv-SE, DateFormat=yyyy-MM-dd, TimeFormat=HH:mm
      C:\Files\FolderScripts\Fix-MailboxFolders.ps1 : Can't access mailbox information store (Exception calling "Bind" with
      "2" argument(s): "The specified object was not found in the store.")
      At line:1 char:1
      + .\Fix-MailboxFolders.ps1 -Mailbox test -Language sv-SE -FromLanguage en-US -verb ...
      + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
          + CategoryInfo          : NotSpecified: (:) [Write-Error], WriteErrorException
          + FullyQualifiedErrorId : Microsoft.PowerShell.Commands.WriteErrorException,Fix-MailboxFolders.ps1
    • Update: The script started working after approximately 15 minutes. Might be worth to notice. However I'm not able to rename well-known folders.
    • "Can't access mailbox information store" is a permissions issue. Permission changes may take upon 15min to propagate. PST folders are regarded as regular folders, so if there's been a name change (Inkorg/Inkorgen) I suggest - temporarily - modifying $LanguageInfo as those folder names are used to look up 'source' folders.