Renewing Teams over PowerShell in bulk / exclude in bulk from policy.

Occasional Contributor

Hey guys,


Just recently have turned on group expiration policy for one client, we done a research and it appeared a great idea, however after some time we got a feedback that some teams need to go back to their documents even 3 years after the Teams channel gets created. And here is the question: is is possible to renew Teams / Outlook Groups in bulk using PowerShell? This particular team told us that they got like hundreds of groups, and renewing them even once a year is a pain. Or maybe there is a way to exclude particular Teams from participating in policy?


Appreciat eyour help,

Kind regards,


2 Replies

There's no "exclude" option, but there is an "include" one, so you can do the opposite. As for bulk renewal, you can use the Graph API:


Hi@Vasil Michev I was tryingn to use Graph API - and almost got it. The problem is that via Graph Explorer I am able to renew the group by using POST groups/{groupid}/renew command - it works great, but when trying to do the same with PowerShell using this command:


Invoke-RestMethod -Uri '<domain>' -Headers $GraphToken -Method POST


I got:


Invoke-RestMethod : {"odata.error":{"code":"Request_BadRequest","message":{"lang":"en","value":"Specified HTTP method is not allowed for the request target."},"requestId":"0b54628a-8859-4c01-ae51-43db84dgf4c0","date":"2019-07-02T13:18:24"}}
At line:1 char:1
+ Invoke-RestMethod -Uri '<domain> ...
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : InvalidOperation: (System.Net.HttpWebRequest:HttpWebRequest) [Invoke-RestMethod], WebException
+ FullyQualifiedErrorId : WebCmdletWebResponseException,Microsoft.PowerShell.Commands.InvokeRestMethodCommand


According to documentation it should work, and it does - using graph explorer on web browser, from some reason it does not work however via powershell.


Was fighting for whole days today - no progress..