Hi all,
I'm having some issues trying to monitor office 365 services health, I have this script that was working but it stopped doing so.
This is the script I'm using:
$tenantId = $args[0]
$client_id = $args[1]
$client_secret = $args[2]
$uri = "https://login.microsoftonline.com/$tenantId/oauth2/v2.0/token"
$body = @{
client_id = $client_id
scope = "https://graph.microsoft.com/.default"
client_secret = $client_secret
grant_type = "client_credentials"
}
$tokenRequest = try {
Invoke-RestMethod -Method Post -Uri $uri -ContentType "application/x-www-form-urlencoded" -Body $body -ErrorAction Stop
}
catch [System.Net.WebException] {
Write-Warning "Exception was caught: $($_.Exception.Message)"
}
$token = $tokenRequest.access_token
$token
Invoke-RestMethod -Method Get -Uri "https://manage.office.com/api/v1.0/$tenantId/ServiceComms/Services" -Headers @{Authorization = "Bearer $token"}
And this is the error I'm getting:
Line |
25 | Invoke-RestMethod -Method Get -Uri "https://manage.office.com/api/v1. …
| ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
| 404 - File or directory not found. Server Error
| 404 - File or directory not found. The resource you are looking for
| might have been removed, had its name changed, or is temporarily
| unavailable.
Hope somebody could help me.
Thank you.