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.