Cloud and Microsoft technologies enthusiast architect in Switzerland RSS 2.0
# Thursday, October 25, 2012

<Caution>This post is based on the SharePoint 2013 Consumer Preview. Thus, behavior described here may change in the next release of the platform</Caution>

When a site collection is created and if the “SharePoint Server Publishing Infrastructure” site collection feature is activated, SharePoint 2013 automatically creates a term group in the term store attached to the web application. This term group can then be used for the navigation. The structure below is therefore created :

newsitecollectiontermgroup

But, when you delete the site collection, the term group and its structure underneath will remain, which can in one sense be understood. The drawback of this is that once the site collection is deleted, you can’t see it in the Term Store Management Tool from the Central Admin site. It also means that if you create a site collection with the same name as the previous one, this term group will be suffixed by a number, like “-1” or “-2”. This can be a bit dirty.

Two possibilities to avoid this situation :

  1. Delete the Term Sets and Term Group from the site collection before its deletion
  2. Use PowerShell to delete these ghost Term Groups if it is too late.

For the second solution, the following script can be used :

$Site = get-SPSite "$url"
$ServiceName = "Managed Metadata Service"
$session = Get-SPTaxonomySession -Site $Site
$termStore = $session.TermStores[$ServiceName]
$termGroup = $termStore.Groups[$termGroupName]

"About to delete Term group in"
"URL : " + $url
"Group : " $termGroup

 
if ($termStore -ne $null)
{
 
    if ($termGroup -ne $null)
    {
        $termGroup.TermSets | ForEach {
            "deleting " + $_.Name
            $_.Delete()
            $termStore.CommitAll()
               $_.Name + "deleted"
        }
        $termGroup.Delete()
        $termStore.CommitAll()
    }
}

$Site represents the target site collection URL, and $termGroupName is the name of the Term Group you want to delete

If you want to check what are the existing Term Groups in your store, you can use this script :

$Site = get-SPSite "$url"
$ServiceName = "Managed Metadata Service"
$session = Get-SPTaxonomySession -Site $Site
$termStore = $session.TermStores[$ServiceName]

"Groups in"
"URL : " + $url
 
if ($termStore -ne $null)
{
    $termStore.Groups | ForEach    {
        $_.Name
    }
}

Thursday, October 25, 2012 1:18:00 AM (GMT Daylight Time, UTC+01:00)  #    Comments [0] -
SP2013
Google Cloud Platform Certified Professional Cloud Architect
Ranked #1 as
French-speaking SharePoint
Community Influencer 2013
Navigation
Currently Reading :
I was there :
I was there :
I was exhibiting at :
I was there :
I was a speaker at :
I was a speaker at :
I was a speaker at
(January 2013 session):
I was a speaker at :
I was a speaker at :
United Nations (UN) SharePoint Event 2011
I was a speaker at :
I was there !
I was there !
I was there !
I was there !
Archive
<November 2020>
SunMonTueWedThuFriSat
25262728293031
1234567
891011121314
15161718192021
22232425262728
293012345
About the author/Disclaimer

Disclaimer
The opinions expressed herein are my own personal opinions and do not represent my employer's view in any way.

© Copyright 2020
Yves Peneveyre
Sign In
Statistics
Total Posts: 289
This Year: 1
This Month: 0
This Week: 0
Comments: 19
Themes
Pick a theme:
All Content © 2020, Yves Peneveyre
DasBlog theme 'Business' created by Christoph De Baene (delarou)