Get-EntraServicePrincipalOwner
Get the owner of a service principal.
Syntax
Get-EntraServicePrincipalOwner
-ObjectId <String>
[-All]
[-Top <Int32>]
[-Property <String[]>]
[<CommonParameters>]
Description
The Get-EntraServicePrincipalOwner cmdlet gets the owners of a service principal in Microsoft Entra ID.
Examples
Example 1: Retrieve the owner of a service principal
Connect-Entra -Scopes 'Application.Read.All'
$ServicePrincipalId = (Get-EntraServicePrincipal -Top 1).ObjectId
Get-EntraServicePrincipalOwner -ObjectId $ServicePrincipalId
ObjectId DisplayName UserPrincipalName UserType
-------- ----------- ----------------- --------
aaaaaaaa-0000-1111-2222-bbbbbbbbbbbb Adams Smith Adams@contoso.com Member
bbbbbbbb-1111-2222-3333-cccccccccccc Peter Kons Peter@contoso.com Member
cccccccc-2222-3333-4444-dddddddddddd Mary Kom Mary@contoso.com Member
The first command gets the ID of a service principal by using the Get-EntraServicePrincipal cmdlet. The command stores the ID in the $ServicePrincipalId variable.
The second command gets the owner of a service principal identified by $ServicePrincipalId.
Example 2: Retrieve all the owners of a service principal
Connect-Entra -Scopes 'Application.Read.All'
$ServicePrincipalId = (Get-EntraServicePrincipal -Top 1).ObjectId
Get-EntraServicePrincipalOwner -ObjectId $ServicePrincipalId -All
ObjectId DisplayName UserPrincipalName UserType
-------- ----------- ----------------- --------
aaaaaaaa-0000-1111-2222-bbbbbbbbbbbb Adams Smith Adams@contoso.com Member
bbbbbbbb-1111-2222-3333-cccccccccccc Peter Kons Peter@contoso.com Member
cccccccc-2222-3333-4444-dddddddddddd Mary Kom Mary@contoso.com Member
This command gets all the owners of a service principal.
Example 3: Retrieve top two owners of a service principal
Connect-Entra -Scopes 'Application.Read.All'
$ServicePrincipalId = (Get-EntraServicePrincipal -Top 1).ObjectId
Get-EntraServicePrincipalOwner -ObjectId $ServicePrincipalId -Top 2
ObjectId DisplayName UserPrincipalName UserType
-------- ----------- ----------------- --------
aaaaaaaa-0000-1111-2222-bbbbbbbbbbbb Adams Smith Adams@contoso.com Member
bbbbbbbb-1111-2222-3333-cccccccccccc Peter Kons Peter@contoso.com Member
This command gets top two owners of a service principal.
Parameters
-All
List all pages.
Type: | System.Management.Automation.SwitchParameter |
Position: | Named |
Default value: | False |
Required: | False |
Accept pipeline input: | False |
Accept wildcard characters: | False |
-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 |
-Property
Specifies properties to be returned
Type: | System.String[] |
Position: | Named |
Default value: | None |
Required: | False |
Accept pipeline input: | False |
Accept wildcard characters: | False |
-Top
Specifies the maximum number of records to return.
Type: | System.Int32 |
Position: | Named |
Default value: | None |
Required: | False |
Accept pipeline input: | True |
Accept wildcard characters: | False |
Related Links
Feedback
https://aka.ms/ContentUserFeedback.
Coming soon: Throughout 2024 we will be phasing out GitHub Issues as the feedback mechanism for content and replacing it with a new feedback system. For more information see:Submit and view feedback for