Skip to content

Commit 301304e

Browse files
1 parent 6fd19d2 commit 301304e

File tree

3 files changed

+63
-45
lines changed

3 files changed

+63
-45
lines changed

articles/20200211-properly-remove-team/index.html

Lines changed: 62 additions & 44 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515

1616

1717

18-
<title>How to quickly and properly delete a Team (without waiting) - Michaël Maillot</title>
18+
<title>How to quickly and properly delete a Teams Team (without waiting) - Michaël Maillot</title>
1919

2020

2121

@@ -64,7 +64,7 @@
6464
<div data-md-component="skip">
6565

6666

67-
<a href="#how-to-quickly-and-properly-delete-a-team-without-waiting" class="md-skip">
67+
<a href="#how-to-quickly-and-properly-delete-a-teams-team-without-waiting" class="md-skip">
6868
Skip to content
6969
</a>
7070

@@ -96,7 +96,7 @@
9696
<div class="md-header__topic" data-md-component="header-topic">
9797
<span class="md-ellipsis">
9898

99-
How to quickly and properly delete a Team (without waiting)
99+
How to quickly and properly delete a Teams Team (without waiting)
100100

101101
</span>
102102
</div>
@@ -344,28 +344,29 @@
344344

345345

346346

347-
<h1 id="how-to-quickly-and-properly-delete-a-team-without-waiting">How to quickly and properly delete a Team (without waiting)</h1>
347+
<h1 id="how-to-quickly-and-properly-delete-a-teams-team-without-waiting">How to quickly and properly delete a Teams Team (without waiting)</h1>
348348
<div class="admonition note">
349-
<p class="admonition-title">Article update</p>
350-
<p>2020-11-29 : I've updated the article following the update of the CLI for Microsoft 365, adding a new command for permanently delete a site collection.</p>
349+
<p class="admonition-title">Article updates</p>
350+
<p><strong>2021-12-03</strong>: article update following CLI for Microsoft 365 updates, adding permanent AAD Group removal and Teams team deletion (optional), adding new PnP PowerShell commands.</p>
351+
<p><strong>2020-11-29</strong>: article update following CLI for Microsoft 365 updates, adding a new command for permanently delete a Site Collection.</p>
351352
</div>
352353
<h2 id="use-case">Use Case</h2>
353354
<p>You work for a company that wants to automatically create a Team with Tabs, Channels and other stuff that will make a new project team ready to rock the stage.</p>
354-
<p>You are preparing the process and for mastering it, you have create / test / destroy / retry. But when you want to clean up your mess, you have to know that, during 30 days:</p>
355+
<p>You are preparing the process and for mastering it, you have createed / tested / destroyed / retried. But when you want to clean up your mess you have to know that, during 30 days:</p>
355356
<ul>
356357
<li>Your Team still exists as a Group (you can find it in the "Deleted Groups" menu on AAD), same for the associated e-mail address</li>
357-
<li>The Team Site also still exists</li>
358+
<li>The Teams site also still exists</li>
358359
</ul>
359360
<p>So let's says that you made a mistake during the creation of a Team and want to "start over" (with same name of course), if you don't want to wait for the Office 365 Job to update your environment and re-create the Team with same name:</p>
360361
<ul>
361362
<li>
362-
<p>The SharePoint Site URL takes a number at the end of its address (of course, because the older one's still here)</p>
363+
<p>The SharePoint site URL takes a number at the end of its address (of course, because the older one's still here)</p>
363364
</li>
364365
<li>
365-
<p>You can't permanently delete the Teams Site, as the SharePoint Admin Center detects that the related Group still exists</p>
366+
<p>You can't permanently delete the Teams site, as the SharePoint Admin Center detects that the related Group still exists</p>
366367
</li>
367368
</ul>
368-
<p>Here's a step by step process to delete quickly a Team ! I recommand to follow them in this order to make everything's work.</p>
369+
<p>Here's a step by step process to delete quickly a Team! I recommend to follow them in this order to make everything's work.</p>
369370
<h2 id="prerequisites">Prerequisites</h2>
370371
<ol>
371372
<li>An Office 365 (Dev) Tenant or a Partner Demo Tenant</li>
@@ -379,7 +380,7 @@ <h2 id="prerequisites">Prerequisites</h2>
379380
</ul>
380381
</li>
381382
<li>Command Interface (one of these)<ul>
382-
<li>PowerShell (with <a href="https://docs.microsoft.com/en-us/powershell/azure/active-directory/install-adv2?view=azureadps-2.0" target="_blank">AzureAD PowerShell</a>, <a href="https://docs.microsoft.com/en-us/powershell/sharepoint/sharepoint-pnp/sharepoint-pnp-cmdlets?view=sharepoint-ps" target="_blank">PnP PowerShell</a> and <a href="https://docs.microsoft.com/en-us/powershell/teams/?view=teams-ps" target="_blank">Microsoft Teams PowerShell</a>)</li>
383+
<li>PowerShell (with <a href="https://docs.microsoft.com/en-us/powershell/azure/active-directory/install-adv2?view=azureadps-2.0" target="_blank">AzureAD PowerShell</a>, <a href="https://pnp.github.io/powershell/" target="_blank">PnP PowerShell</a> and <a href="https://docs.microsoft.com/en-us/powershell/teams/?view=teams-ps" target="_blank">Microsoft Teams PowerShell</a>)</li>
383384
<li><a href="https://pnp.github.io/cli-microsoft365/" target="_blank">CLI for Microsoft 365</a></li>
384385
</ul>
385386
</li>
@@ -390,21 +391,40 @@ <h3 id="delete-group-with-interface">Delete Group with Interface</h3>
390391
<p><img alt="alt text" src="../../images/articles/20200211/delete-group.png" title="Delete Group" /></p>
391392
<p><img alt="alt text" src="../../images/articles/20200211/perm-delete-group.png" title="Permanently Delete Group" /></p>
392393
<h3 id="delete-group-with-code">Delete Group with code</h3>
393-
<div class="tabbed-set" data-tabs="1:2"><input checked="checked" id="__tabbed_1_1" name="__tabbed_1" type="radio" /><label for="__tabbed_1_1">Azure AD PowerShell</label><div class="tabbed-content">
394+
<div class="tabbed-set" data-tabs="1:3"><input checked="checked" id="__tabbed_1_1" name="__tabbed_1" type="radio" /><label for="__tabbed_1_1">PnP PowerShell</label><div class="tabbed-content">
394395
<table class="highlighttable"><tr><td class="linenos"><div class="linenodiv"><pre><span></span><span class="normal">1</span>
395396
<span class="normal">2</span>
396-
<span class="normal">3</span></pre></div></td><td class="code"><div class="highlight"><pre><span></span><code><span class="nb">Connect-AzureAD</span> <span class="n">-TenantId</span> <span class="s2">&quot;TenantId&quot;</span>
397-
<span class="nb">Remove-AzureADGroup</span> <span class="n">-ObjectId</span> <span class="s2">&quot;GroupId&quot;</span>
398-
<span class="nb">Remove-AzureADMSDeletedDirectoryObject</span> <span class="n">-Id</span> <span class="s2">&quot;GroupId&quot;</span>
397+
<span class="normal">3</span>
398+
<span class="normal">4</span>
399+
<span class="normal">5</span>
400+
<span class="normal">6</span>
401+
<span class="normal">7</span>
402+
<span class="normal">8</span>
403+
<span class="normal">9</span></pre></div></td><td class="code"><div class="highlight"><pre><span></span><code><span class="c"># If you are familiar with the Get-PnPStoredCredential cmdlet,</span>
404+
<span class="c"># you can use it here with the &quot;-Credential&quot; Argument</span>
405+
<span class="nb">Connect-PnPOnline</span> <span class="n">-Url</span> <span class="s2">&quot;https://contoso-admin.sharepoint.com&quot;</span>
406+
407+
<span class="c"># Remove the Group</span>
408+
<span class="nb">Remove-PnPMicrosoft365Group</span> <span class="n">-Identity</span> <span class="s2">&quot;GroupId&quot;</span>
409+
410+
<span class="c"># Remove the Group from AAD deleted groups (can take a few seconds to be reflected in the UI)</span>
411+
<span class="nb">Remove-PnPDeletedMicrosoft365Group</span> <span class="n">-Identity</span> <span class="s2">&quot;GroupId&quot;</span>
399412
</code></pre></div>
400413
</td></tr></table>
401414
</div>
402415
<input id="__tabbed_1_2" name="__tabbed_1" type="radio" /><label for="__tabbed_1_2">CLI for Microsoft 365</label><div class="tabbed-content">
403416
<table class="highlighttable"><tr><td class="linenos"><div class="linenodiv"><pre><span></span><span class="normal">1</span>
417+
<span class="normal">2</span></pre></div></td><td class="code"><div class="highlight"><pre><span></span><code>m365 login
418+
m365 aad o365group remove --id <span class="s2">&quot;GroupId&quot;</span> --skipRecycleBin --confirm
419+
</code></pre></div>
420+
</td></tr></table>
421+
</div>
422+
<input id="__tabbed_1_3" name="__tabbed_1" type="radio" /><label for="__tabbed_1_3">Azure AD PowerShell</label><div class="tabbed-content">
423+
<table class="highlighttable"><tr><td class="linenos"><div class="linenodiv"><pre><span></span><span class="normal">1</span>
404424
<span class="normal">2</span>
405-
<span class="normal">3</span></pre></div></td><td class="code"><div class="highlight"><pre><span></span><code><span class="c1"># (As there&#39;s no CLI command to permanently delete a Group,</span>
406-
<span class="c1"># you&#39;ll have to do it through the UI)</span>
407-
aad o365group remove --id <span class="s2">&quot;GroupId&quot;</span> --confirm
425+
<span class="normal">3</span></pre></div></td><td class="code"><div class="highlight"><pre><span></span><code><span class="nb">Connect-AzureAD</span> <span class="n">-TenantId</span> <span class="s2">&quot;TenantId&quot;</span>
426+
<span class="nb">Remove-AzureADGroup</span> <span class="n">-ObjectId</span> <span class="s2">&quot;GroupId&quot;</span>
427+
<span class="nb">Remove-AzureADMSDeletedDirectoryObject</span> <span class="n">-Id</span> <span class="s2">&quot;GroupId&quot;</span>
408428
</code></pre></div>
409429
</td></tr></table>
410430
</div>
@@ -417,7 +437,25 @@ <h3 id="delete-team-with-interface">Delete Team with Interface</h3>
417437
<p><center><strong>OR</strong></center></p>
418438
<p><img alt="alt text" src="../../images/articles/20200211/delete-team-admin.png" title="Delete Team from Admin Interface" /></p>
419439
<h3 id="delete-team-with-code">Delete Team with code</h3>
420-
<div class="tabbed-set" data-tabs="2:1"><input checked="checked" id="__tabbed_2_1" name="__tabbed_2" type="radio" /><label for="__tabbed_2_1">Microsoft Teams PowerShell</label><div class="tabbed-content">
440+
<div class="admonition warning">
441+
<p class="admonition-title">Warning<p>As the AAD Group removal triggers automatically the Teams Team deletion you can skip this part.</p>
442+
</p>
443+
</div>
444+
<div class="tabbed-set" data-tabs="2:3"><input checked="checked" id="__tabbed_2_1" name="__tabbed_2" type="radio" /><label for="__tabbed_2_1">PnP PowerShell</label><div class="tabbed-content">
445+
<table class="highlighttable"><tr><td class="linenos"><div class="linenodiv"><pre><span></span><span class="normal">1</span>
446+
<span class="normal">2</span></pre></div></td><td class="code"><div class="highlight"><pre><span></span><code><span class="c"># Remove the Team</span>
447+
<span class="nb">Remove-PnPTeamsTeam</span> <span class="n">-Identity</span> <span class="s2">&quot;GroupId&quot;</span> <span class="n">-Force</span>
448+
</code></pre></div>
449+
</td></tr></table>
450+
</div>
451+
<input id="__tabbed_2_2" name="__tabbed_2" type="radio" /><label for="__tabbed_2_2">CLI for Microsoft 365</label><div class="tabbed-content">
452+
<table class="highlighttable"><tr><td class="linenos"><div class="linenodiv"><pre><span></span><span class="normal">1</span>
453+
<span class="normal">2</span></pre></div></td><td class="code"><div class="highlight"><pre><span></span><code><span class="c1"># Remove the Team</span>
454+
m365 teams team remove --teamId <span class="s2">&quot;GroupId&quot;</span> --confirm
455+
</code></pre></div>
456+
</td></tr></table>
457+
</div>
458+
<input id="__tabbed_2_3" name="__tabbed_2" type="radio" /><label for="__tabbed_2_3">Microsoft Teams PowerShell</label><div class="tabbed-content">
421459
<table class="highlighttable"><tr><td class="linenos"><div class="linenodiv"><pre><span></span><span class="normal">1</span>
422460
<span class="normal">2</span></pre></div></td><td class="code"><div class="highlight"><pre><span></span><code><span class="nb">Connect-MicrosoftTeams</span> <span class="n">-TenantId</span> <span class="s2">&quot;TenantId&quot;</span>
423461
<span class="nb">Remove-Team</span> <span class="n">-GroupId</span> <span class="s2">&quot;GroupId&quot;</span>
@@ -426,39 +464,19 @@ <h3 id="delete-team-with-code">Delete Team with code</h3>
426464
</div>
427465
</div>
428466
<h2 id="delete-site-collection">Delete Site Collection</h2>
429-
<p>As I told you before (even if you did the previous steps), if you try to delete the Teams Site from the SharePoint Admin Center, you won't be able to remove it from the Site Collection Recycle Bin (because of the O365 Job Tenant update process).</p>
467+
<p>As I told you before (even if you did the previous steps), if you try to delete the Teams site from the SharePoint Admin Center, you won't be able to remove it from the Site Collection Recycle Bin (because of the O365 Job Tenant update process).</p>
430468
<h3 id="delete-site-with-code">Delete site with code</h3>
431469
<div class="tabbed-set" data-tabs="3:2"><input checked="checked" id="__tabbed_3_1" name="__tabbed_3" type="radio" /><label for="__tabbed_3_1">PnP PowerShell</label><div class="tabbed-content">
432470
<table class="highlighttable"><tr><td class="linenos"><div class="linenodiv"><pre><span></span><span class="normal">1</span>
433-
<span class="normal">2</span>
434-
<span class="normal">3</span>
435-
<span class="normal">4</span>
436-
<span class="normal">5</span>
437-
<span class="normal">6</span>
438-
<span class="normal">7</span>
439-
<span class="normal">8</span>
440-
<span class="normal">9</span></pre></div></td><td class="code"><div class="highlight"><pre><span></span><code><span class="c"># If you are familiar with the Get-PnPStoredCredential cmdlet,</span>
441-
<span class="c"># you can use it here with the &quot;-Credential&quot; Argument</span>
442-
<span class="nb">Connect-PnPOnline</span> <span class="n">-TenantId</span> <span class="s2">&quot;TenantId&quot;</span>
443-
444-
<span class="c"># Remove the site</span>
471+
<span class="normal">2</span></pre></div></td><td class="code"><div class="highlight"><pre><span></span><code><span class="c"># Remove the site</span>
445472
<span class="nb">Remove-PnPTenantSite</span> <span class="n">-Url</span> <span class="s2">&quot;TeamsSiteUrl&quot;</span> <span class="n">-Force</span> <span class="n">-SkipRecycleBin</span>
446-
447-
<span class="c"># Remove the site from the Site Collection Recycle Bin</span>
448-
<span class="nb">Clear-PnPTenantRecycleBinItem</span> <span class="n">-Url</span> <span class="s2">&quot;TeamsSiteUrl&quot;</span> <span class="n">-Force</span> <span class="n">-Wait</span>
449473
</code></pre></div>
450474
</td></tr></table>
451475
</div>
452476
<input id="__tabbed_3_2" name="__tabbed_3" type="radio" /><label for="__tabbed_3_2">CLI for Microsoft 365</label><div class="tabbed-content">
453477
<table class="highlighttable"><tr><td class="linenos"><div class="linenodiv"><pre><span></span><span class="normal">1</span>
454-
<span class="normal">2</span>
455-
<span class="normal">3</span>
456-
<span class="normal">4</span>
457-
<span class="normal">5</span></pre></div></td><td class="code"><div class="highlight"><pre><span></span><code><span class="c1"># Remove the site</span>
458-
spo site classic remove -u <span class="s2">&quot;TeamsSiteUrl&quot;</span> --skipRecycleBin --confirm --wait
459-
460-
<span class="c1"># Remove the site from the Site Collection Recycle Bin</span>
461-
spo tenant recyclebinitem remove -u <span class="s2">&quot;TeamsSiteUrl&quot;</span> --confirm --wait
478+
<span class="normal">2</span></pre></div></td><td class="code"><div class="highlight"><pre><span></span><code><span class="c1"># Remove the site</span>
479+
m365 spo site remove -u <span class="s2">&quot;TeamsSiteUrl&quot;</span> --skipRecycleBin --confirm --wait
462480
</code></pre></div>
463481
</td></tr></table>
464482
</div>

search/search_index.json

Lines changed: 1 addition & 1 deletion
Large diffs are not rendered by default.

sitemap.xml.gz

0 Bytes
Binary file not shown.

0 commit comments

Comments
 (0)