Check the purpose of the Exchange mailbox

Each mailbox created in Exchange Online has its own purpose. The mailbox can be associated with a user account or shared by two or more user accounts; it can represent either a conference room or a piece of equipment.

When you call /users endpoint, the response also contains objects that are associated either with a shared mailbox, a room or, a piece of equipment.

How you can distinguish between different types of resources?

Mailbox settings

At first sight, the user resource type doesn't have any useful property except one. Settings for the primary mailbox of the user: mailboxSettings. The property mailboxSettings can be read only when retrieving a single user, not within a user collection.

To read mailbox settings, specify the mailboxSettings property in $select query parameter when retrieving a single user.

GET /me?$select=mailboxSettings
GET /users/{user_id}?$select=mailboxSettings

Or access the mailboxSettings property directly

GET /me/mailboxSettings
GET /users/{user_id}/mailboxSettings

Reading mailbox settings requires either delegated or application permission MailboxSettings.Read. With the delegated permission, you will be able to read the mailbox settings of the signed-in user. You cannot read the mailbox settings of another user.

With application permission, you can read the mailbox settings of all users, except guests.

The response from /users/{user_id}/mailboxSettings contains the following settings:

  • automatic replies (notify people automatically upon receipt of their email)
  • date format
  • delegateMeetingMessageDeliveryOptions
  • locale (language and country/region)
  • time format
  • time zone
  • working hours
  • user purpose
{
    "archiveFolder": "...",
    "timeZone": "Central Europe Standard Time",
    "delegateMeetingMessageDeliveryOptions": "sendToDelegateOnly",
    "dateFormat": "dd.MM.yyyy",
    "timeFormat": "H:mm",
    "userPurpose": "user",
    "automaticRepliesSetting": {
        "status": "disabled",
        "externalAudience": "none",
        "internalReplyMessage": "...",
        "externalReplyMessage": "...",
        "scheduledStartDateTime": {
            "dateTime": "2023-08-04T10:00:00.0000000",
            "timeZone": "UTC"
        },
        "scheduledEndDateTime": {
            "dateTime": "2023-08-05T10:00:00.0000000",
            "timeZone": "UTC"
        }
    },
    "language": {
        "locale": "cs-CZ",
        "displayName": "Czech (Czech Republic)"
    },
    "workingHours": {
        "daysOfWeek": [
            "monday",
            "tuesday",
            "wednesday",
            "thursday",
            "friday"
        ],
        "startTime": "07:00:00.0000000",
        "endTime": "16:00:00.0000000",
        "timeZone": {
            "name": "Central Europe Standard Time"
        }
    }
}

The userPurpose property is exactly what we need. It describes the purpose of the mailbox. Differentiates a mailbox for a single user from a shared mailbox and a piece of equipment mailbox in Exchange Online.

Possible values are:

Value Description
user A user account with a mailbox in the local forest
linked A mailbox linked to a user account in another forest
shared A mailbox shared by two or more user accounts
room A mailbox that represents a conference room
equipment A mailbox that represents a piece of equipment
others A mailbox was found but the user purpose is different from the ones specified in the previous scenarios

Script

With the Microsoft Graph PowerShell SDK (version > 2.1), you can read the mailbox settings by calling Get-MgUserMailboxSetting cmdlet

$settings = Get-MgUserMailboxSetting -UserId "{user_id}" -Property "userPurpose"
$settings.UserPurpose

You can find the script in the GitHub repo.

0
Buy Me a Coffee at ko-fi.com
An error has occurred. This application may no longer respond until reloaded. Reload x