$OAuthUri =
'https://login.microsoftonline.com/common/oauth2/token'
$Body =
@{
resource = 'https://graph.microsoft.com'
client_id = 'getyourclientid'
client_secret = 'getyourclientsecret'
grant_type = 'client_credentials'
redirectUri = "https://localhost:8000"
}
$Response =
Invoke-RestMethod -Method
Post -Uri
$OAuthUri -Body
$Body
$Authorization =
Invoke-RestMethod -Method
Post -Uri
$OAuthUri -Body
$Body -ContentType
"application/x-www-form-urlencoded"
-UseBasicParsing
Write-output
$Authorization
$access_token =
$Authorization.access_token
Write-output
$Authorization.access_token
$Headers =
@{ Authorization = "Bearer
$($Response.access_token)" }
$Uri =
"https://graph.microsoft.com/getyourtenantname/alerts"
$Results =
Invoke-RestMethod -Uri
$Uri -ContentType
application/json -Method
Get -Headers
$Headers
Write-output
$Results