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

Copper 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,

J

7 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: https://docs.microsoft.com/en-us/graph/api/grouplifecyclepolicy-renewgroup?view=graph-rest-beta&tabs...

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 'https://graph.windows.net/<domain>.onmicrosoft.com/groups/8c8dce4c-9e61-4617-b111-22073d5f6d39/renew...' -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 'https://graph.windows.net/<domain>.onmicrosoft.co ...
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ 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..

@Pawel Jarosz  Hello.  I am very curious did you get this to function properly?

Well we gave up on this - I mean on group expiration. The reason was sometimes someone might forgot to renew the group and the group expires - and here we got a problem. The group got removed and we couldn't restore it back, we engaged MS, appeared that we needed to use owner account that created the team - thank God we haven't removed the AD account yet - so it couldn't be any owner but the owner who created the team. There are two problems tho - if group has more than one owner / or the owner changed over time it is not possible to check who actually created the team - or I was not able to find it, and second: the restore process haven't restored that chat. As this expire/restore process was so dodgy - we revoke this setting and resigned from using this expiration feature at all since then. Time flies so it might changed but we haven't got time or noone was interested one more time in using this feature.
Oh my. Thank you for this information that is... unsettling. We have legality concerns for data retention.
If you have access to the Teams Admin center you might have permissions to restore Groups/Teams Workspaces you are not even a member of. Not sure about the chat history that might be something to check if you're still interested in attempting. (Bulk "visiting" or "renewing" is something I still haven't figured out.)
Thanks for reply, I was not performing this - just colleagues from IT support, maybe something changed - need to test it out. Time has passed - maybe some things have been rectified.

Cheers,
Pawel