How to Retrieve App Registration Owner Details in Azure Entra ID Using PowerShell?

Subhash Kumar Mahato 265 Reputation points
2024-10-14T05:03:12.62+00:00

Hi,

I am trying to obtain the owner details of an Azure Entra ID (formerly Azure AD) App Registration. My goal is to write a PowerShell script that sends an email notification when the secret value is about to expire (7 days in advance).

I can successfully retrieve the app registration details using the Az.Resources module with the Get-AzADAppCredential cmdlet. However, when I attempt to get the owner details, I encounter issues.

I have also tried using the PowerShell cmdlet Get-AzADApplication -ObjectId $AppObjectId, but the owner information returned is blank.

Can anyone guide me on how to retrieve the app registration owner details using PowerShell? Any insights or examples would be greatly appreciated!

Thanks!

Microsoft Security | Microsoft Entra | Microsoft Entra ID
0 comments No comments
{count} votes

Accepted answer
  1. Andreas Baumgarten 123.7K Reputation points MVP Volunteer Moderator
    2024-10-14T06:21:11+00:00

    Hi @Subhash Kumar Mahato ,

    did you try Get-MgApplicationOwner to get the required information?

    For example:

    Get-MgApplicationOwner -ApplicationId $(Get-MgApplication -Filter "DisplayName eq '<Displayname of your App Registration>'").Id
    
    

    More details: Get-MgApplicationOwner

    Get-MgApplicationOwner is a cmdlet of the Microsoft Graph PowerShell Module.


    (If the reply was helpful please don't forget to upvote and/or accept as answer, thank you)

    Regards

    Andreas Baumgarten


1 additional answer

Sort by: Most helpful
  1. Navya 20,490 Reputation points Microsoft External Staff Moderator
    2024-10-16T03:47:28.36+00:00

    Hi @Subhash Kumar Mahato

    Thank you for posting this in Microsoft Q&A.

    I understand that you want to retrieve App Registration Owner Details in Azure Entra ID using PowerShell.

    Can you please try the command below

    $owners = Get-MgApplicationOwner -ApplicationId <your application id>
    $userDetails = @()
    foreach ($owner in $owners) {
        $userInfo = Get-MgUser -UserId $owner.Id
        if ($userInfo) {
            $userDetails += [PSCustomObject]@{
                Id                = $userInfo.Id
                DisplayName       = $userInfo.DisplayName
                UserPrincipalName = $userInfo.UserPrincipalName
            }
        }
    }
    $userDetails
    
    
    

    Hope this helps. Do let us know if you any further queries.

    Thanks,

    Navya.


    If this answers your query, do click Accept Answer and Yes for was this answer helpful. And, if you have any further query do let us know.

    1 person found this answer helpful.
    0 comments No comments

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.