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
Add a comment
|
1 Answer
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