Home

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

%3CLINGO-SUB%20id%3D%22lingo-sub-730755%22%20slang%3D%22en-US%22%3ERenewing%20Teams%20over%20PowerShell%20in%20bulk%20%2F%20exclude%20in%20bulk%20from%20policy.%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-730755%22%20slang%3D%22en-US%22%3E%3CP%3EHey%20guys%2C%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EJust%20recently%20have%20turned%20on%20group%20expiration%20policy%20for%20one%20client%2C%20we%20done%20a%20research%20and%20it%20appeared%20a%20great%20idea%2C%20however%20after%20some%20time%20we%20got%20a%20feedback%20that%20some%20teams%20need%20to%20go%20back%20to%20their%20documents%20even%203%20years%20after%20the%20Teams%20channel%20gets%20created.%20And%20here%20is%20the%20question%3A%20is%20is%20possible%20to%20renew%20Teams%20%2F%20Outlook%20Groups%20in%20bulk%20using%20PowerShell%3F%20This%20particular%20team%20told%20us%20that%20they%20got%20like%20hundreds%20of%20groups%2C%20and%20renewing%20them%20even%20once%20a%20year%20is%20a%20pain.%20Or%20maybe%20there%20is%20a%20way%20to%20exclude%20particular%20Teams%20from%20participating%20in%20policy%3F%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EAppreciat%20eyour%20help%2C%3C%2FP%3E%3CP%3EKind%20regards%2C%3C%2FP%3E%3CP%3EJ%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-LABS%20id%3D%22lingo-labs-730755%22%20slang%3D%22en-US%22%3E%3CLINGO-LABEL%3Eexclude%3C%2FLINGO-LABEL%3E%3CLINGO-LABEL%3EExpiration%20Policy%3C%2FLINGO-LABEL%3E%3CLINGO-LABEL%3EPowerShell%3C%2FLINGO-LABEL%3E%3C%2FLINGO-LABS%3E%3CLINGO-SUB%20id%3D%22lingo-sub-731940%22%20slang%3D%22en-US%22%3ERe%3A%20Renewing%20Teams%20over%20PowerShell%20in%20bulk%20%2F%20exclude%20in%20bulk%20from%20policy.%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-731940%22%20slang%3D%22en-US%22%3E%3CP%3EThere's%20no%20%22exclude%22%20option%2C%20but%20there%20is%20an%20%22include%22%20one%2C%20so%20you%20can%20do%20the%20opposite.%20As%20for%20bulk%20renewal%2C%20you%20can%20use%20the%20Graph%20API%3A%26nbsp%3B%3CA%20href%3D%22https%3A%2F%2Fdocs.microsoft.com%2Fen-us%2Fgraph%2Fapi%2Fgrouplifecyclepolicy-renewgroup%3Fview%3Dgraph-rest-beta%26amp%3Btabs%3Dcs%22%20target%3D%22_blank%22%20rel%3D%22noopener%20noreferrer%20noopener%20noreferrer%20noopener%20noreferrer%22%3Ehttps%3A%2F%2Fdocs.microsoft.com%2Fen-us%2Fgraph%2Fapi%2Fgrouplifecyclepolicy-renewgroup%3Fview%3Dgraph-rest-beta%26amp%3Btabs%3Dcs%3C%2FA%3E%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-734336%22%20slang%3D%22en-US%22%3ERe%3A%20Renewing%20Teams%20over%20PowerShell%20in%20bulk%20%2F%20exclude%20in%20bulk%20from%20policy.%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-734336%22%20slang%3D%22en-US%22%3E%3CP%3EHi%3CA%20href%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fuser%2Fviewprofilepage%2Fuser-id%2F58%22%20target%3D%22_blank%22%3E%40Vasil%20Michev%3C%2FA%3E%20I%20was%20tryingn%20to%20use%20Graph%20API%20-%20and%20almost%20got%20it.%20The%20problem%20is%20that%20via%20Graph%20Explorer%20I%20am%20able%20to%20renew%20the%20group%20by%20using%20POST%20groups%2F%7Bgroupid%7D%2Frenew%20command%20-%20it%20works%20great%2C%20but%20when%20trying%20to%20do%20the%20same%20with%20PowerShell%20using%20this%20command%3A%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EInvoke-RestMethod%20-Uri%20'%3CA%20href%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2F%22%20target%3D%22_blank%22%20rel%3D%22noopener%20noreferrer%22%3Ehttps%3A%2F%2Fgraph.windows.net%2F%3CDOMAIN%3E.onmicrosoft.com%2Fgroups%2F8c8dce4c-9e61-4617-b111-22073d5f6d39%2Frenew%2F%3Fapi-version%3D1.6%3C%2FDOMAIN%3E%3C%2FA%3E'%20-Headers%20%24GraphToken%20-Method%20POST%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EI%20got%3A%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EInvoke-RestMethod%20%3A%20%7B%22odata.error%22%3A%7B%22code%22%3A%22Request_BadRequest%22%2C%22message%22%3A%7B%22lang%22%3A%22en%22%2C%22value%22%3A%22Specified%20HTTP%20method%20is%20not%20allowed%20for%20the%20request%20target.%22%7D%2C%22requestId%22%3A%220b54628a-8859-4c01-ae51-43db84dgf4c0%22%2C%22date%22%3A%222019-07-02T13%3A18%3A24%22%7D%7D%3CBR%20%2F%3EAt%20line%3A1%20char%3A1%3CBR%20%2F%3E%2B%20Invoke-RestMethod%20-Uri%20'%3CA%20href%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2F%22%20target%3D%22_blank%22%20rel%3D%22noopener%20noreferrer%22%3Ehttps%3A%2F%2Fgraph.windows.net%2F%3CDOMAIN%3E.onmicrosoft.co%3C%2FDOMAIN%3E%3C%2FA%3E%20...%3CBR%20%2F%3E%2B%20~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~%3CBR%20%2F%3E%2B%20CategoryInfo%20%3A%20InvalidOperation%3A%20(System.Net.HttpWebRequest%3AHttpWebRequest)%20%5BInvoke-RestMethod%5D%2C%20WebException%3CBR%20%2F%3E%2B%20FullyQualifiedErrorId%20%3A%20WebCmdletWebResponseException%2CMicrosoft.PowerShell.Commands.InvokeRestMethodCommand%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EAccording%20to%20documentation%20it%20should%20work%2C%20and%20it%20does%20-%20using%20graph%20explorer%20on%20web%20browser%2C%20from%20some%20reason%20it%20does%20not%20work%20however%20via%20powershell.%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EWas%20fighting%20for%20whole%20days%20today%20-%20no%20progress..%3C%2FP%3E%3C%2FLINGO-BODY%3E
Highlighted
Pawel Jarosz
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,

J

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: 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..

Related Conversations
Tabs and Dark Mode
cjc2112 in Discussions on
16 Replies
flashing a white screen while open new tab
cntvertex in Discussions on
11 Replies
How to Prevent Teams from Auto-Launch
chenrylee in Microsoft Teams on
28 Replies
Early preview of Microsoft Edge group policies
Sean Lyndersay in Discussions on
65 Replies