Monday, July 18, 2016

Finding duplicate content types

Got to a chance to build a script for finding content type duplicates in a Site Collection

#Description:Find duplicate content types in sitecollection

Add-PSSnapin microsoft.sharepoint.powershell

$siteURL = "https://test-mysite.mycompany.com"
$site = get-spsite $siteURL
$object = @()

foreach ($newWeb in $site.AllWebs) {
    foreach ($cType in $newWeb.contentTypes) {
        $tempObj = new-object PSObject -Property @{webURL=$newWeb.Url; CTName=$cType.Name; CTid=$cType.Id}
        $object += $tempObj
        }
    }
#sort out duplicates
$duplicates = $object |Group-Object ctid |Where-Object {$_.count -gt 1} |select -ExpandProperty group

write-output "Found $($object.count) content types in $siteURL"
write-output "Total duplicates: $($duplicates.count)"
$duplicates

No comments:

Powershell and Uptimerobot

Uptimerobot can be quite tedious when you need to update many monitors at once. For example say you bought the license for Uptimerobot and n...