SharePoint Duplicate Key
In SharePoint 2010 or 2013 it's possible that when try to open "content or structure" on the settings.aspx page or when try to open a list or all lists that you get an error telling you that a duplicate key exists. The duplicate key is related to a list somewhere in the SharePoint site-collection.
The issue is at hand is that you won't be able to find it using the GUI. So i thought i would share my powershell script that will check for duplicate lists / keys so that you know which list to remove via disabling a feature or just by removing it with powershell. (will also work with host named site collections)
code:
Function Get-Duplicate {
param($array, [switch]$count)
begin {
$hash = @{}
}
process {
$array | %{ $hash[$_] = $hash[$_] + 1 }
if($count) {
$hash.GetEnumerator() | ?{$_.value -gt 1} | %{
New-Object PSObject -Property @{
Value = $_.key
Count = $_.value
}
}
}
else {
$hash.GetEnumerator() | ?{$_.value -gt 1} | %{$_.key}
}
}
}
#Itterating through lists in web for duplicate objects
$webapps = get-spwebapplication
Foreach ($wa in $webapps)
{
$sites = $wa.Sites
Foreach ($site in $sites)
{
$Webs = $site.AllWebs
Foreach ($web in $webs)
{
write-host -foregroundcolor DarkGreen $web.url
$Lists = $web.Lists
$array = @()
$lists | %{$array += $_.Title}
Get-Duplicate $array
}
}
}
Reacties
Een reactie posten