Share via

Delete all Microsoft Graph subscriptions

Pascal Kesseli 21 Reputation points
2021-12-14T19:24:08.533+00:00

Our organisation contains a large number of Microsoft Graph subscriptions which are not longer necessary - the associated REST endpoint has been shut down. Is there a way to purge all Microsoft Graph subscriptions in one go, as to not have them trigger unnecessary events anymore? Retrieving them all using Get-MgSubscription and deleting them using Remove-MgSubscription takes a very long time.

Thank you for any help with this issue and kind regards,

Community Center | Not monitored
0 comments No comments

1 answer

Sort by: Most helpful
  1. Diana Wanjuhi 1,376 Reputation points
    2021-12-20T10:14:59.507+00:00

    Hello @Pascal Kesseli Thank you for reaching out. There are two ways you might get around this:

    1. PowerShell ForEach-Object Parallel Feature to parallelize the tasks: #get all $subscriptions = Get-MgSubscription $subscriptions | ForEach-Object -Parallel -ThrottleLimit $subscriptions.Count { try{Remove-MgSubscription -id $_.id } }
    2. Combing multiple http requests using JSON Batching and Invoke-MgGraphRequest

    Let me know whether this helps and if you have further questions,

    Diana.

    Was this answer helpful?

    0 comments No comments

Your answer

Answers can be marked as 'Accepted' by the question author and 'Recommended' by moderators, which helps users know the answer solved the author's problem.