New-ServicePrincipal : A parameter cannot be found that matches parameter name 'ObjectId'

Yasitha Pandithawatta 141 Reputation points
2024-04-05T00:51:41.2433333+00:00

I have a strage error when I execute the below cmdlet in exchange online management.

New-ServicePrincipal -AppId xxx -ObjectId xxx -DisplayName "xxx"

Error: New-ServicePrincipal : A parameter cannot be found that matches parameter name 'ObjectId'

I have logged in with Connect-ExchangeOnline cmdlet with a user with Organization Management role.

I have checked and user is a part if RoleManagement.

PS C:\Users\Administrator> Get-ManagementRole -Cmdlet New-ServicePrincipal
Name            RoleType
----            --------
Role Management RoleManagement

According to the documentation, ObjectId is a valid param. https://learn.microsoft.com/en-us/powershell/module/exchange/new-serviceprincipal?view=exchange-ps

Microsoft Exchange Online
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,859 questions
{count} votes

2 answers

Sort by: Most helpful
  1. Shweta Mathur 30,276 Reputation points Microsoft Employee
    2024-04-05T07:15:13.5766667+00:00

    Hi @Yasitha Pandithawatta ,

    Thanks for reaching out.

    To Register Service Principal in Exchange:

    New-ServicePrincipal -AppId <APPLICATION_ID> -ServiceId <OBJECT_ID> [-Organization <ORGANIZATION_ID>]

    Make sure to use ObjectId from enterprise applications rather than object id of application registration. For the same application you registered in Application Registration. A corresponding application has been created in Enterprise Application as well. You need to pass object id from there while registering service principal in Exchange.

    User's image

    Hope this will help.

    Thanks,

    Shweta

    Please remember to "Accept Answer" if answer helped you.

    2 people found this answer helpful.

  2. Yuki Sun-MSFT 41,341 Reputation points
    2024-04-05T01:56:50.1866667+00:00

    Hi @Yasitha Pandithawatta ,

    I have logged in with Connect-ExchangeOnline cmdlet with a user with Organization Management role.

    Normally, the organization management role would be enough to use the ObjectID parameter of New-ServicePrincipal cmdlet:User's image

    For your situation, could you try typing "New-ServicePrincipal -O" and then pressing Tab and see if the "-ObjectID" parameter can be automatically filled?
    User's image User's image

    It's also suggested to try connecting to Exchange Online PowerShell with another user who has the Organization Management role and see if there would be any difference.


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

    Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.


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.