List columns where Content Type is used

Recently, I had to know which CT was using a column, with the following PS was very easy to do it:

$site = Get-SPSite https://webapp
$web = $site.RootWeb

$columnName = "Yourcolumnname"
$guid = $web.fields[$columnName].id

$contentTypes = $web.AvailableContentTypes
for ($x=0; $x -lt $contentTypes.Count; $x++)
{
for ($y=0; $y -lt $contentTypes[$x].Fields.Count; $y++)
{
if ($contentTypes[$x].Fields[$y].id -eq $guid)
{
Write-Host $contentTypes[$x].Name " contains column " $columnName
}
}
}
Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s