2

I would like to know if there is a power shell script that will go through all libraries/lists on a single SP2013 farm and give me an output where a certain content type is still in use?
I want to remove certain content types added to task lists that was used for workflow purposes but not necessary any more

1 Answer 1

2

you can use this script:

This script takes 2 arguments:

  • Web URL - This is a fully qualified URL to the site.
  • Content Type Name - This is the content type name.

So using the script would look like the following:

Find-Content-Types.ps1 "http://SPURL/SITE" "CONTENT TYPE NAME"

Hope it helps!

Add-PSSnapin "Microsoft.SharePoint.PowerShell"
$webUrl=$args[0]
$ctName=$args[1]
$count=0
$site=get-spsite $webUrl
Write-Host "Starting search...." 
foreach($web in $site.AllWebs)
{
    foreach($lst in $web.lists)
    {
        foreach($ctype in $lst.ContentTypes)
        {
            if($ctype.Name -eq $ctName)
            {
                Write-Host $lst.DefaultViewUrl -ForegroundColor Yellow
                $count++
            }
        }
    }
    $web.Dispose()
}
Write-Host "Found $count lists using the content type '$ctName'." -ForegroundColor Green
2
  • Thank you so much Zdenek - work like a charm!
    – Hes JvR
    Commented Feb 7, 2019 at 8:51
  • You're welcome. Commented Feb 7, 2019 at 8:52

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.