0

Looking for a way to locate a field by it's GUID in my site collection...any one know a way to do this in powershell and dump out where the field is being used?

  • You want to know where the field has been used within the Site Collection? – Arsalan Adam Khatri Mar 26 '14 at 15:24
  • yes, so i can find out where it could be located and remove it if necessary. – Jacob A Mar 26 '14 at 17:08
2

The following should help, I haven't tested it yet..

$fieldId = [Guid]"fa564e0f-0c70-4ab9-b863-0177e6ddd247"

$site = Get-SPSite("http://yoursite/") 

foreach($web in $site.AllWebs)  
{            
  foreach($list in $web.Lists)  
  {
    $fieldInUseList = $list.Fields | Where {$_.Id -eq $fieldId }
    if($fieldInUseCt) {
        Write-Host "'$web' web - Found a match in the '$field' field in the '$list' list"
    }            
  }
  foreach($ct in $web.ContentTypes) {
     $fieldInUseCt = $ct.FieldLinks | Where {$_.Id -eq $fieldId }
     if($fieldInUseCt) {
        Write-Host "'$web' web - Found a match in the '$field' field in the '$ct' Contenttype"
     }
  }
}

PS: I haven't dispose any of the Webs or Site Collection itself for simplicity..

For removing you can see the below reference:

PowerShell – Delete field and all references

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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