Add-MailboxPermission : The term ‘Add-MailboxPermission’ is not recognized

Nisha 41 Reputation points
2024-07-22T15:31:34.2266667+00:00

Hi,

We are using the following command to connect to ExchangeOnline using Service Principal:

Connect-ExchangeOnline -AppId $Application.AppId -CertificateThumbprint $thumb -Organization "OrganizationName"

It connected with no errors.

The following command, however, gives this error message:

Add-MailboxPermission -Identity “usermailbox” -User “userthatneedsaccess” -AccessRights FullAccess -InheritanceType All

The term ‘Add-MailboxPermission’ is not recognized as the name of a cmdlet, function, script file, or operable program.

When connecting using a service account, the 'Add-MailboxPermission' command does not give this error.

We are trying to migrate to using Service Principals. Can someone please help us here?

Thanks in advance!

Microsoft Exchange Online Management
Microsoft Exchange Online Management
Microsoft Exchange Online: A Microsoft email and calendaring hosted service.Management: The act or process of organizing, handling, directing or controlling something.
4,569 questions
{count} votes

Accepted answer
  1. Vasil Michev 107.7K Reputation points MVP
    2024-07-22T15:34:42.1233333+00:00

    Did you assign an admin role to the service principal? Step 5 here: https://learn.microsoft.com/en-us/powershell/exchange/app-only-auth-powershell-v2?view=exchange-ps#step-5-assign-microsoft-entra-roles-to-the-application

    This is a mandatory step, you cannot skip it. If you do not want to assign a "wide" Entra ID role, you can use the Exchange RBAC model instead, read here: https://learn.microsoft.com/en-us/exchange/permissions-exo/application-rbac

    1 person found this answer helpful.

1 additional answer

Sort by: Most helpful
  1. Xintao Qiao-MSFT 3,695 Reputation points Microsoft Vendor
    2024-07-23T03:00:01.3633333+00:00

    Hi, @Nisha

    I couldn't agree more with Vasil Michev 's idea. You may need at least the appropriate permissions to use the above commands. You can read the article above first.

    In addition, according to other users, Microsoft has applied some updates that may affect permissions. Removing and reapplying these permissions may resolve the issue. More information can be found Add-MailboxPermission : The term 'Add-MailboxPermission' is not recognized - Collaboration - Spiceworks Community

    If the answer is helpful, please click "Accept Answer" and kindly upvote it. If you have extra questions about this answer, please click "Comment".

    0 comments No comments

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.