Add-EntraServicePrincipalOwner
Add an owner (user or service principal) to a service principal.
Syntax
ByServicePrincipalIdAndOwnerId
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.
Parameter properties
Type: | System.String |
Default value: | None |
Supports wildcards: | False |
DontShow: | False |
Aliases: | RefObjectId |
Parameter sets
(All)
Position: | Named |
Mandatory: | True |
Value from pipeline: | True |
Value from pipeline by property name: | True |
Value from remaining arguments: | False |
-ServicePrincipalId
Specifies the ID of a service principal in Microsoft Entra ID.
Parameter properties
Type: | System.String |
Default value: | None |
Supports wildcards: | False |
DontShow: | False |
Aliases: | ObjectId |
Parameter sets
(All)
Position: | Named |
Mandatory: | True |
Value from pipeline: | True |
Value from pipeline by property name: | True |
Value from remaining arguments: | False |
CommonParameters
This cmdlet supports the common parameters: -Debug, -ErrorAction, -ErrorVariable, -InformationAction, -InformationVariable, -OutBuffer, -OutVariable, -PipelineVariable, -ProgressAction, -Verbose, -WarningAction, and -WarningVariable. For more information, see about_CommonParameters.