In Microsoft Entra ID (Azure AD), every enterprise app has a service principal. And just like app registrations, service principals should have clear ownership. Owners are the people (or other service principals) who are allowed to manage the object. Microsoft also recommends keeping at least two owners for proper governance.
That’s where Get-MgServicePrincipalOwner helps. It lets you quickly list the owners of a service principal so you can:
Try the M365Corner Microsoft 365 Reporting Tool — your DIY pack with 20+ out-of-the-box M365 reports for Users, Groups, and Teams.
Module: Microsoft.Graph.Applications
Get-MgServicePrincipalOwner
-ServicePrincipalId <String>
[-ExpandProperty <String[]>]
[-Property <String[]>]
[-All]
To read service principal owners, you need one of the following Graph permissions. These are the same permission families used for service principal read operations.
Delegated:
Application (app-only):
Connect example:
Connect-MgGraph -Scopes "Application.Read.All","Directory.Read.All"
Get-MgServicePrincipalOwner
What this does:
Prompts you for the ServicePrincipalId, then returns the owners of that service principal.
Get-MgServicePrincipalOwner -ServicePrincipalId <serviceprincipalid>
What this does:
Retrieves owners of the specified service principal. Here you directly pass the -ServicePrincipalId without being prompted by the console.
Get-MgServicePrincipalOwner -ServicePrincipalId <serviceprincipalid> | export-csv d:/serviceprincipalowners.csv
What this does:
Exports the owners list to CSV for governance reviews or audit evidence.
Install-Module Microsoft.Graph.Applications -Scope CurrentUser
Import-Module Microsoft.Graph.Applications
The cmdlet lives in Microsoft.Graph.Applications.
ServicePrincipalId ≠ AppId
If you only have AppId, resolve it first:
$sp = Get-MgServicePrincipalByAppId -AppId ""
Get-MgServicePrincipalOwner -ServicePrincipalId $sp.Id
Note: you can get both app id and service principal id using Get-MgServicePrincipal cmdlet.
Get-MgServicePrincipalOwner -ServicePrincipalId <id> -All
Graph returns paged results by default.
Here’s where admins typically use this cmdlet:
| Error | Cause | Solution |
|---|---|---|
| The term Get-MgServicePrincipalOwner is not recognized…” | Module missing or not imported. | Install-Module Microsoft.Graph.Applications Import-Module Microsoft.Graph.Applications |
| Insufficient privileges to complete the operation | Missing Graph scopes / admin consent | Connect-MgGraph -Scopes "Application.Read.All","Directory.Read.All" If app-only, ensure those permissions are granted and admin-consented. |
| Resource not found” / empty owners list | Wrong ID (AppId passed instead of ServicePrincipal ObjectId) Service principal really has no owners |
|
Get-MgServicePrincipalOwner is a simple but powerful governance cmdlet. It helps you quickly identify who owns an enterprise app (service principal), which is vital for:
In large tenants, combine it with -All and ensure you pass the ServicePrincipal ObjectId for accurate output.
© m365corner.com. All Rights Reserved. Design by HTML Codex