Assigning Owner to Application Registration and Enterprise Application using PowerShell?

EnterpriseArchitect 6,301 Reputation points
2024-03-04T03:43:15.1033333+00:00

How can I use Microsoft PowerShell script to assign an Application or Service principal in Azure to a single user?

I have a list of the application names in a TXT file like below:

App1
WebApplication1
CloudApps1
....
App-X

However, when browsing the page I cannot find the cmdlet to add a set or even update:

https://learn.microsoft.com/en-us/powershell/module/microsoft.graph.applications/get-mgapplicationowner?view=graph-powershell-1.0

Thank you in advance,

Windows for business | Windows Server | User experience | PowerShell
Microsoft Security | Microsoft Entra | Microsoft Entra ID
Microsoft Security | Microsoft Graph
Microsoft Security | Microsoft Entra | Other
{count} votes

Answer accepted by question author
  1. CarlZhao-MSFT 46,406 Reputation points
    2024-03-04T06:45:25.5366667+00:00

    Hi @EnterpriseArchitect

    You can run the New-MgApplicationOwnerByRef cmdlet to add an owner to the target app.

    Import-Module Microsoft.Graph.Applications
    
    $params = @{
    	"@odata.id" = "https://graph.microsoft.com/v1.0/directoryObjects/{user id}"
    }
    
    New-MgApplicationOwnerByRef -ApplicationId $appObjectId -BodyParameter $params
    

    Or run the Remove-MgApplicationOwnerByRef cmdlet to remove the app owner.

    Hope this helps.

    If the reply is helpful, please click Accept Answer and kindly upvote it. If you have additional questions about this answer, please click Comment.

    1 person found this answer helpful.

1 additional answer

Sort by: Most helpful
  1. Gudivada Adi Navya Sri 21,080 Reputation points Moderator
    2024-03-04T09:07:35.4866667+00:00

    Hi @EnterpriseArchitect

    Thank you for posting this in Microsoft Q&A.

    Adding to the above information provided by CarlZhao-MSFT.To add an owner to an Enterprise application using Microsoft Graph PowerShell.

    Connect-MgGraph -Scopes 'Application.ReadWrite.All'
    
    $owner = @{ 
    "@odata.id" = "https://graph.microsoft.com/v1.0/directoryObjects/{id}"
     } 
    
    New-MgServicePrincipalOwnerByRef -ServicePrincipalId $servicePrincipalId -BodyParameter $owner
    

    To get owners of the Enterprise Application use Get-MgServicePrincipalOwnerByRef

    To get owners of the Application Registration use Get-MgApplicationOwnerByRef

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

    Thanks,

    Navya.

    1 person found this answer helpful.

Your answer

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