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

Leave a Reply

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

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

Facebook photo

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

Connecting to %s