79361944

Date: 2025-01-16 14:29:17
Score: 0.5
Natty:
Report link

With some slight tweaking this seems to be working for Graph. Thank you Glen. Still getting issues with it being unauthorized for Exchange Online. For the Exchange app for Graph and the Exchange permissions mentioned earlier, I granted both delegate and application API permissions on the app (not sure which one did the job yet until I play about removing permissions to see what exactly is needed).

This is the code for Graph:

$CalendarPermissionsClientSecret = ConvertTo-SecureString "CENSORED" - 
AsPlainText -Force
$CalendarPermissionsClientID="CENSORED"
$CalendarPermissionsTenantID="CENSORED"
$MsalParams = @{
ClientId = $CalendarPermissionsClientID
TenantId = $CalendarPermissionsTenantID
ClientSecret = $CalendarPermissionsClientSecret
Scopes="https://graph.microsoft.com/.default"
}
 $Pwd = ConvertTo-SecureString $password -AsPlainText -Force


 $MsalResponse = Get-MsalToken @MsalParams

$global:CalendarPermissionsToken = ConvertTo-SecureString 
$MsalResponse.AccessToken -AsPlainText -Force

Connect-mggraph -AccessToken $CalendarPermissionsToken

Get-MgUser

The command then works fine.

Reasons:
  • Blacklisted phrase (0.5): Thank you
  • Long answer (-1):
  • Has code block (-0.5):
  • Self-answer (0.5):
  • Low reputation (1):
Posted by: Alan1987