Add-EntraServicePrincipalOwner

Adds an owner to a service principal.

Syntax

Add-EntraServicePrincipalOwner
    -ObjectId <String>
    -RefObjectId <String> 
   [<CommonParameters>]

Description

The Add-EntraServicePrincipalOwner cmdlet adds an owner to a service principal in Microsoft Entra ID.

Examples

Example 1: Add a user as an owner to a service principal

Connect-Entra -Scopes 'Application.ReadWrite.All','Application.ReadWrite.OwnedBy'
$ServicePrincipalId = (Get-EntraServicePrincipal -Top 1).ObjectId
$OwnerId = (Get-EntraUser -Top 1).ObjectId
$Params = @{
    ObjectId = $ServicePrincipalId 
    RefObjectId = $OwnerId  
}
Add-EntraServicePrincipalOwner @Params

This example demonstrates how to add an owner to a service principal.

  • -ObjectId parameter specifies the service principal ID.
  • -RefObjectId parameter specifies the user object ID.

Parameters

-ObjectId

Specifies the ID of a service principal in Microsoft Entra ID.

Type:System.String
Position:Named
Default value:None
Required:True
Accept pipeline input:True
Accept wildcard characters:False

-RefObjectId

Specifies the ID of the Microsoft Entra ID object to assign as owner/manager/member.

Type:System.String
Position:Named
Default value:None
Required:True
Accept pipeline input:True
Accept wildcard characters:False