Skip to content

Instantly share code, notes, and snippets.

@mikeplate
Created August 6, 2013 06:08
Show Gist options
  • Select an option

  • Save mikeplate/6162420 to your computer and use it in GitHub Desktop.

Select an option

Save mikeplate/6162420 to your computer and use it in GitHub Desktop.
Find all Content Types and Lists where a particular column is used within a site collection
param (
[String]$SiteUrl = 'http://spdev',
[String]$FieldName = 'Title'
)
Add-PSSnapin Microsoft.SharePoint.PowerShell -ErrorAction SilentlyContinue
$site = Get-SPSite $SiteUrl
"Showing where ""$FieldName"" is used"
foreach ($web in $site.AllWebs) {
foreach ($ctype in $web.ContentTypes) {
if ($ctype.Fields.ContainsField($FieldName)) {
$web.Url + ' Content Type: ' + $ctype.Name
}
}
foreach ($list in $web.Lists) {
if ($list.Fields.ContainsField($FieldName)) {
$web.Url + ' List: ' + $list.Title
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment