Add-EntraServicePrincipalOwner

Adds an owner to a service principal.

Syntax

Add-EntraServicePrincipalOwner
   -ServicePrincipalId <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 = @{
    ServicePrincipalId = $ServicePrincipalId 
    RefObjectId = $OwnerId  
}
Add-EntraServicePrincipalOwner @Params

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

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

Parameters

-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

-ServicePrincipalId

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

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