PowerShell script to find and remove duplicate items from do
Hi Friends,
Please check this below script, It is finding the duplicate items and removing it. This script is not working to find the duplicate items from document library and remove. Can you please let me know where it is wrong.
Add-PSSnapin microsoft.sharepoint.powershell
$web = Get-SPWeb -Identity "http://zapltvsspdev02:4333/bu/EXCO"
$list = $web.Lists["AECI Documents"]
$AllDuplicates = $list.Items.GetDataTable() | Group-Object INumber | where {$_.count -gt 1}
$count = 1
$max = $AllDuplicates.Count
foreach($duplicate in $AllDuplicates)
{
$duplicate.group | Select-Object -Skip 1 | % {$list.GetItemById($_.ID).Delete()}
Write-Progress -PercentComplete ($count / $max * 100) -Activity "$count duplicates removed" -Status "In Progress"
$count++
}
Remove-PsSnapin Microsoft.SharePoint.PowerShell
Note:
In the above code, duplicates are found using the "INumber" column.