Take the 2-minute tour ×
SharePoint Stack Exchange is a question and answer site for SharePoint enthusiasts. It's 100% free, no registration required.

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.

share|improve this question

1 Answer 1

up vote 1 down vote accepted

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())  
        }   
    }   
}
share|improve this answer
    
Perfect. Thank you Brandon. You rock. (well, rock is hard and senseless). You smooth. LOL –  Maria Burton Jul 2 '12 at 15:52
    
I changed get_InternalName to get_Title cause the column name was renamed. Thanks –  Maria Burton Jul 2 '12 at 16:37

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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