Finding out where a list column is used in a site collection

There are times when you need to know where a specific list column is being used in your site collection. This is especially true for custom columns that you may have created. The following script can be used to find which lists are using a specific column name. (I posted this script on the SharePoint TechNet forum in response to a question.)


[System.Reflection.Assembly]::Load("Microsoft.SharePoint, Version=12.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c") | out-null

[void][System.reflection.Assembly]::LoadWithPartialName("Microsoft.SharePoint")

# set-up working variables...

# Enter your SharePoint site collection URL here...

$TargetSiteUrl = "http://sharepoint_site_collection_URL"

# Enter the list column name you want to find here...

$FieldToFind = "Title"

# Starting search

write-host "FieldName, ListName, ListURL"

$spSite = new-object Microsoft.SharePoint.SPSite($TargetSiteUrl)

$colWebsites = $spSite.AllWebs

foreach ($web in $colWebsites)
{

$colLists = $web.Lists

foreach ($list in $colLists)
{

$fields = $list.Fields

foreach ($item in $fields)
{

If ($item.Title.Contains($FieldToFind))
{
write-host  $item.Title, ";", $list.Title, ";", $list.DefaultViewUrl
}

}

}

}

write-host "Finished."

Advertisements

0 Responses to “Finding out where a list column is used in a site collection”



  1. Leave a Comment

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




RSS Information Week Headlines

  • An error has occurred; the feed is probably down. Try again later.

RSS SharePoint Team Blog

  • An error has occurred; the feed is probably down. Try again later.

RSS InfoPath Team Blog

  • An error has occurred; the feed is probably down. Try again later.

RSS Joel Oleson Blog

  • An error has occurred; the feed is probably down. Try again later.

RSS Susan Hanley’s KM Blog

  • An error has occurred; the feed is probably down. Try again later.

Blog Stats

  • 348,120 hits

%d bloggers like this: