One question we often get in support is, “How do I find all my Planner plans?” The answer to this is not too tricky—the tricky bit is ‘all plans; rather than ‘all my plans’—as, due to security and pr...
Thanks for this script - its getting me very close to what i need.
I'm still having issues with not having the required permissions to access the items, on about 90% of the groups in our entra tennant. i have added User.Read.All and Groups.Read.All to the AppRego API perms, but still no dice.
i am authenticating with my Global Admin after presenting the AppID - so i should not have any issues. Any ideas?
added some colour to help differentiate all the line items (i have 1000's of groups)
Side note: I implemented a throttling module also, as we have a lot of groups. its probing for the status code 429, and issuing a retry when detected. Works nicely!
added some "start-sleep" commands to slow the entire thing down a bit too.
Module code:
function Throttle {
param (
[int]$retryAfter
)
Write-Host "Throttled by M365. Waiting for $retryAfter seconds before retrying..."
Start-Sleep -Seconds $retryAfter
}
and then the updated try-catch block:
try {
$plans = Invoke-WebRequest -Uri $uri -Method Get -Headers $headers -Body $parameters -UseBasicParsing
if ($plans.StatusCode -eq '200') {
$plansContent = $plans.Content | ConvertFrom-Json
$plansContentValues = $plansContent.value
ForEach ($value in $plansContentValues) {
Write-host -ForegroundColor DarkYellow " Plan ID = "$value.id
Write-host -ForegroundColor DarkGreen " Plan title = "$value.title
Start-Sleep -Milliseconds 100
}
} else {
Write-host "Likely permissions issue with " $value.displayname "site/plan"
}
} catch {
if ($_.Exception.Response.StatusCode -eq 429) {
$retryAfter = [int]$_.Exception.Response.Headers["Retry-After"]
Throttle -retryAfter $retryAfter
# Retry the request after waiting
$plans = Invoke-WebRequest -Uri $uri -Method Get -Headers $headers -Body $parameters -UseBasicParsing
} else {
not200
Write-host -ForegroundColor DarkRed " No access to group - "$value.displayname " with the /planner/plans call"
Start-Sleep -Milliseconds 100
}
}
Might help someone out there, if they are getting hit with throttling from Entra.