For the latest version of this code please visit msgraph-sdk-powershell-examples.

Deprecated Content

Granting a Managed Identity (Automation Account or Logic App) access to a Microsoft Graph using the Microsoft Graph SDK for PowerShell and the Get-MgServicePrincipal and New-MgServicePrincipalAppRoleAssignment cmdlets.

PowerShell Code

Note: This code requires the Microsoft Graph SDK for PowerShell.