I have created PowerShell 7 Azure Function (AF) and a managed service identity (MSI) with reader role across the entire subscription. Using this code here:
Connect-AzAccount -Identity
$token = Get-AzAccessToken -ResourceUrl "https://graph.microsoft.com"
Connect-MgGraph -AccessToken $token.Token
The connection, via Graph works as I receive the 'Hello to Graph' in the (AF) log window. However, when searching for a user;
get-mgUser -userID 'objectID of the user'
I receive permission denied. Using:
connect-mgGraph -Scopes
Prompts for an interactive login...
Looking at the Enterprise application registration for the MSI, I'm unable to grant any permissions (logged in as GA). Can someone point me in the right direction please?