issue giving managed identity exchange admin role

Aran Billen 516 Reputation points
2024-04-17T14:55:50.2666667+00:00

I am trying to give a managed identity exhcange admin role to run automations in azure however when using

$MIAppID = 'my id'
$params = @{
    ServicePrincipalId = $MIAppID # managed identity object id
    PrincipalId = $MIAppID # managed identity object id
    ResourceId = (Get-MgServicePrincipal -Filter "AppId eq '00000002-0000-0ff1-ce00-000000000000'").id # Exchange online
    AppRoleId = "dc50a0fb-09a3-484d-be87-e023b12c6440" # Exchange.ManageAsApp
}
New-MgServicePrincipalAppRoleAssignedTo @params

I get: The 'Get-mgserviceprincipal' command was found in the module 'Microsoft.Graph.Applications', but the module could not be loaded. For more information, run 'Import-Module Microsoft.Graph.Applications'.

I then install the latest verson but still the same issue? Any ideas where I am going wrong?

Microsoft Exchange Online
Microsoft Graph
Microsoft Graph
A Microsoft programmability model that exposes REST APIs and client libraries to access data on Microsoft 365 services.
10,610 questions
PowerShell
PowerShell
A family of Microsoft task automation and configuration management frameworks consisting of a command-line shell and associated scripting language.
2,065 questions
0 comments No comments
{count} votes

Accepted answer
  1. Andy David - MVP 141.9K Reputation points MVP
    2024-04-17T16:50:05.7966667+00:00
    1. reboot your workstation and try again
    2. remove the graph module - all of it and remove any graph modules directories remaining under your users dir at Documents\PowerShell\Modules or C:\Program Files\PowerShell\Modules
    3. Reinstall the module: with an all users scope: Install-Module Microsoft.Graph -Scope AllUsers
    0 comments No comments

0 additional answers

Sort by: Most helpful