ConnectorsTeamScrnx - sample script for you to work with. If you need more help, open a support ticket. This isn't the best place to get help for something like this.
Install PowerShell Gallery | MSAL.PS 2.5.0.1
- Run the sample script, update the highlighted parts.
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
User token sample:
$login = "https://login.microsoftonline.com/"
$tenantId = your_tenant_id
$scopes = New-Object System.Collections.ObjectModel.Collection["string"]
$scopes.Add("https://outlook.office365.com/.default")
$authorty=$login + $tenantId
$clientId=your_client_app_id
$authenticationResult = Get-MsalToken -ClientId $clientId -TenantId $tenantId -Scopes $scopes -RedirectUri your_redirect_url
$headers = @{
"Authorization" = ("Bearer {0}" -f $authenticationResult.AccessToken)
}
Invoke-WebRequest 'https://outlook.office365.com/ecp/reportingwebservice/reporting.svc/MessageTrace' -Headers $headers -UseBasicParsing
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
App only token sample:
$login = "https://login.microsoftonline.com/"
$tenantId = your_tenant_id
$scopes = New-Object System.Collections.ObjectModel.Collection["string"]
$scopes.Add("https://outlook.office365.com/.default")
$authorty=$login + $tenantId
$clientId = your_client_id
$ClientCertificate = (Get-ChildItem 'Cert:\CurrentUser\My\your_thumbprint_id')
$authenticationResult = Get-MsalToken -ClientId $clientId -TenantId $tenantId -ClientCertificate $ClientCertificate -Authority $authorty -Scopes $scopes
$headers = @{
"Authorization" = ("Bearer {0}" -f $authenticationResult.AccessToken)
}
$result=Invoke-WebRequest 'https://outlook.office365.com/ecp/reportingwebservice/reporting.svc/MessageTrace' -Headers $headers -UseBasicParsing