Изменить

Поделиться через


Add-EntraServicePrincipalOwner

Add an owner (user or service principal) to a service principal.

Syntax

Add-EntraServicePrincipalOwner
   -ServicePrincipalId <String>
   -OwnerId <String>
   [<CommonParameters>]

Description

The Add-EntraServicePrincipalOwner cmdlet adds an owner to a service principal in Microsoft Entra ID. The owner can be a user, the service principal itself, or another service principal.

Examples

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

Connect-Entra -Scopes 'Application.ReadWrite.All', 'Application.ReadWrite.OwnedBy'
$servicePrincipal = Get-EntraServicePrincipal -Filter "displayName eq 'Helpdesk Application'"
$owner = Get-EntraUser -UserId 'SawyerM@contoso.com'
Add-EntraServicePrincipalOwner -ServicePrincipalId $servicePrincipal.Id -OwnerId $owner.Id

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

  • -ServicePrincipalId parameter specifies the service principal ID.
  • -OwnerId parameter specifies the unique ID of the owner, which can be a user, the service principal itself, or another service principal.

Example 2: Add a service principal as an owner

Connect-Entra -Scopes 'Application.ReadWrite.All', 'Application.ReadWrite.OwnedBy'
$servicePrincipal = Get-EntraServicePrincipal -Filter "displayName eq 'Helpdesk Application'"
$owner = Get-EntraServicePrincipal -Filter "displayName eq 'IT Department'"
Add-EntraServicePrincipalOwner -ServicePrincipalId $servicePrincipal.Id -OwnerId $owner.Id

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

  • -ServicePrincipalId parameter specifies the service principal ID.
  • -OwnerId parameter specifies the unique ID of the owner, which can be a user, the service principal itself, or another service principal.

Parameters

-OwnerId

Specifies the unique ID of the owner, which can be a user, the service principal itself, or another service principal.

Type:System.String
Aliases:RefObjectId
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