Im trying to setup xoauth2 for our helpdesk aplication.
Im following below commands to configure exchange.
Install-Module -Name ExchangeOnlineManagement
Install-Module Microsoft.Graph
Install-Module -Name AzureAD
import-module AzureAD
Import-module ExchangeOnlineManagement
Connect-AzureAd -Tenant “TenantID”
Connect-ExchangeOnline -Organization “TenantID”
$MyApp = Get-AzureADServicePrincipal -SearchString “YourAppName”
New-ServicePrincipal -AppId $MyApp.AppId -ServiceId $MyApp.ObjectId -DisplayName "Service Principal for IMAP APP"
Add-MailboxPermission -Identity "******@gianmariaricci.onmicrosoft.com" -User $MyApp.ObjectId -AccessRights FullAccess
Do you have any ideas why New-ServicePrincipal cmdlet is not working?