Forum Discussion
Renewing Teams over PowerShell in bulk / exclude in bulk from policy.
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=cs
HiVasilMichev 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/?api-version=1.6' -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..
- GerardoJayJul 08, 2021Copper Contributor
Pawel Jarosz Hello. I am very curious did you get this to function properly?
- Pawel JaroszJul 09, 2021Brass ContributorWell 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.
- GerardoJayJul 13, 2021Copper ContributorIf 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.)