1

http://msdn.microsoft.com/en-us/library/microsoft.sharepoint.spfield.listsfieldusedin.aspx

$web = Get-SPWeb http://”sitecollectionurl”
$column = $web.Fields[“Column Display Name”]
$column.ListsFieldUsedIn()
$allCT = $web.ContentTypes
foreach (SPContentType $ct in $allct)
{
  # Need help here so I can find the field in question
}

returns nada. do i need to add

I am trying to delete a field and it said it's in used by some content type.

2 Answers 2

1

I found a powershell script from: http://netsourcecode.blogspot.com/2011/12/listing-all-content-types-and-fields.html and modified it.

Try this:

$columnname = "StartDate"

write-host ("Looking for: " + $columnname)      
$url=  "http://localhost/"  
$site = get-spsite $url         
$web = $site.OpenWeb()      
foreach ($contenttype in $web.ContentTypes) {   
    foreach ($field in $contenttype.Fields) {
        if ($field.get_InternalName() -eq $columnname) {
            write-host("Content Type Name: " + $contenttype.Name + " has field: " + $field.get_InternalName())  
        }   
    }   
}
2
  • Perfect. Thank you Brandon. You rock. (well, rock is hard and senseless). You smooth. LOL Jul 2, 2012 at 15:52
  • 1
    I changed get_InternalName to get_Title cause the column name was renamed. Thanks Jul 2, 2012 at 16:37
0

Instead of ListsFieldUsedIn, try to use $column.UsedInWebContentTypes()

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.