Get-MailboxFolder is not working & Exchange Web Services…getting started

Triggered by a comment/question  from Robbie De Sutter, on one of my previous blog posts (Exchange 2010: And then there is the long awaited cmdlet Add-MailboxFolderPermission), being:

First of all I'm running an international business, hence my users do not have a "Calendar" folder, but an "Agenda" (Dutch) or "Kalendar" (German) or ... How to deal with that (without me tracking which language every user is using)?

it got me thinking if there was an easy way, out of the box, to get a list like “user x has a Kalendar”, “user y has a Calendar”, and “user z is happy with his Calendrier”"…

Option 1. Use the cmdlet Get-MailboxFolder

Exchange 2010 provides you with a cmdlet named “Get-MailboxFolder”, which is described on TechNet as one that will “retrieve folders for a specified mailbox when the mailbox owner runs the command”, so let’s see. Logged in as Administrator on my demo machine, I can run the cmdlet, and get an overview of all mailbox folders for my own account…


but when trying to run the cmdlet against another user’s mailbox, the following error pops up:

The specified mailbox “ilvancri” doesn’t exist”, whereas the mailbox definitely exists, as can be seen by running the cmdlet Get-Mailbox ilvancri:


Looking back at the TechNet article, it did state “when the mailbox owner runs the command”, thinking about RBAC, it’s time to see who is allowed to run the cmdlet Get-MailboxFolder, by running the following “Get-ManagementRole –Cmdlet “get-mailboxfolder”


The return shows that the role “MyBaseOptions”, scoped to Self, is the only one that is allowed to run the cmdlet Get-MailboxFolder.


Now, one might thing….easy….let’s create a new role, pick MyBaseOptions as the parent role, and change the ImplicitRecipientReadScope to OrganizationConfig…but that won’t work…as seen here on TechNet (Understanding Management Role Scopes) which clearly states:

“You can't change the implicit scopes defined on management roles. You can, however, override the implicit write scope and configuration scope on a management role. When a predefined relative scope or custom scope is used on a role assignment, the implicit write scope or configuration scope of the role is overridden, and the new scope takes precedence. The implicit read scope of a role can't be overridden and always applies. For more information about predefined or custom explicit scopes, see the related sections later in this topic.”

Using Bing, I came across this TechNet forum article: Get-MailboxFolder cmdlet is not working, which describes what I had seen, but it did include a solution, submitted by Exchange MVP Amit Tank, “to use in that case programmatic way with EWS would be easier way to query folders for other users...”, followed by a reply from the original poster being “Thanks Amit, I did it using EWS, specifically I used FindFolderType for this.”

Time to use EWS…

Option 2. Use EWS and FindFolderType

Searching the internet, it was easy to find a ton of scripts, using FindFolderType, but since I’m not a developer, it wasn’t easy to get started (copy-paste of script in Notepad didn’t do it ;-)), so therefore I want to show you how easy it is to get started with EWS and show you a very easy script that will retrieve folders and show them in a simple msgbox 🙂

Step 1. Install Visual Studio

I decided to install Visual Studio 2010 Premium on a Windows 2008 R2 standalone server, so not a member my Exchange demo environment.

Step 2. Download and Install the Exchange Managed API

“The Microsoft Exchange Web Services (EWS) Managed API 1.0 provides a managed interface for developing client applications that use Exchange Web Services. The EWS Managed API simplifies the implementation of applications that communicate with Microsoft Exchange Server 2007 Service Pack 1 (SP1) and later versions of Microsoft Exchange. Built on the Exchange Web Services SOAP protocol and Autodiscover, the EWS Managed API provides a .NET interface to EWS that is easy to learn, use, and maintain.”

I downloaded and installed version 1.0, but there is also a version 1.1 in beta now:



Step 3. Launch Visual Studio

I decided to create a new Windows Form Application



In the Solution Explorer, I expand my project, called Hello World, and right-click References


There is select to Add a reference


And I browse to the location of the Microsoft.Exchange.WebServices.dll which has been installed by deploying the EWS Managed API!


After clicking OK I can see that I have a reference to Microsoft.Exchange.WebServices.


Using the toolbox, it’s easy to create a new button, and enter some code, as said, VERY SIMPLE code, I’m a newbie 🙂

The code below will send an email to ilvancri..

using System;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using Microsoft.Exchange.WebServices.Data;
using System.Net;

namespace Hello_World
    public partial class Form1 : Form
        public Form1()

        private void button1_Click(object sender, EventArgs e)
            ExchangeService service = new ExchangeService();
            service.Credentials = new NetworkCredential("user", "<password>",”<domain>");
            service.Url = new Uri("
            EmailMessage message = new EmailMessage(service);
            message.Subject = "Hello from the EWS Managed API";
            message.Body = "Now that's easy!";



And this one will show the mailbox folder names for a user called user5

private void button2_Click(object sender, EventArgs e)
    ExchangeService service = new ExchangeService(ExchangeVersion.Exchange2010);
    service.Credentials = new NetworkCredential("user", "<password>",”<domain>");
    service.Url = new Uri("
    FolderView view = new FolderView(30, 1, OffsetBasePoint.Beginning);
    view.PropertySet = new PropertySet(BasePropertySet.IdOnly);
    view.Traversal = FolderTraversal.Shallow;
    FindFoldersResults findfolderresults = service.FindFolders(WellKnownFolderName.MsgFolderRoot, view);
    foreach (Folder myfolder in findfolderresults.Folders)
       MessageBox.Show("Folder: " + myfolder.DisplayName);


To find out more about Exchange Web Services, and dive into some examples, I strongly encourage you to have a look at the following links:

Once I do have a script that creates the desired output of user x has calendar, user z has a calendrier, I’ll let you know….


Comments (9)

  1. Joel says:

    Great info, I've personally been thinking about learn more EWS myself. Not a Dev either, if you come across any other good links where to get started with basic scripts would be great!

  2. Supernova says:

    Good blog item with clear examples! It seems that EWS is more for the inside operations of a user's mailbox e.g. create folder, send mail.. When it comes to creating a mailbox on the Exchange 2010 server, what would be the best approach? Via C# code or via Powershell? We have a C# service application which has to create a mailbox for new users. Any help on this appreciated!

  3. Martin says:

    You could list the folders with Get-MailboxFolderStatistics -id | fl folderpath > folders.txt

  4. Anonymous says:

    Pingback from Find Users Missing Email Folders Using Get-MailboxFolderStatistics

  5. islander says:

    Martin – You are da man bro! you solved problem with just one string of command. I would give you a 5 stars on here if I could.

  6. EC says:

    Martin!….Bro! You are the man! Thanks

  7. Romil says:

    In addition to Martin’s cmd:
    Get-MailboxFolderStatistics identity| fl folderpath | measure
    gives you the exact count

  8. Volker says:

    Alternative you can use:
    [string[]] $FolderPaths = Get-MailboxfolderStatistics ALIAS | % {$_.folderpath}
    It will list all Folders.

  9. show box says:

    Thanks for the great info. I really loved this. I would like to apprentice at the same time as you amend your web site, how could i subscribe for a blog site?
    For more info on showbox please refer below sites:
    Latest version of Showbox App download for all android smart phones and tablets. – It’s just 2 MB file you can easily get it on your android device without much trouble. Showbox app was well designed application for android to watch movies and TV shows, Cartoons and many more such things on your smartphone.
    For showbox on iOS (iPhone/iPad), please read below articles:
    Showbox for PC articles:
    There are countless for PC clients as it is essentially easy to understand, simple to introduce, gives continuous administration, effectively reasonable. it is accessible at completely free of expense i.e., there will be no establishment charges and after establishment
    it doesn’t charge cash for watching films and recordings. Not simply watching, it likewise offers alternative to download recordings and motion pictures. The accompanying are the strides that are to be taken after to introduce Showbox application on Android. The above
    all else thing to be done is, go to the Security Settings on your Android telephone, Scroll down and tap on ‘Obscure sources’.
    Movie Box, an esteemed movies application in which you can find stacks of programs and films. The guide is given here to download Movie Box app to Android and to Apple iOS 9.0.2, iOS 8.4/8.3 and also for the lower versions without Jailbreak.
    Please do login to Showbox application with the help of Ymail. You can login in Ymail from here –
    Sign Up & Do registration for latest movies on Showbox application

Skip to main content