0

I am attempting to write a powershell script to pull content type names applied to lists, and their respective parent content type name. Unfortunately, I seem to have run into a hurdle - whenever I attempt to pull "$contenttype.Parent.Name" it returns the name of the content type I am currently querying - not its parent content type name.

Reading online, I see many examples which work with GUID's but I do not need something so precise or complex - I only want the name of the parent for the current content type.

The following is the relevant code I am working with:

  foreach ($listct in $list.ContentTypes)
  {
    $ctname = $listct.name
    $ctgroup = $listct.Group
    $ctparent = $listct.Parent.Name
  }

How can I grab the Parent Content type's name?

2

I think what you are hitting is that SharePoint, when a content type is associated with a specific lists, adds an extra GUID to the Content Type ID.

This makes it a child content type if the original one, even if it theoretically is not.

You should be able to get the correct parent content type by doing something like:

$listct.Parent.Parent.Name
2
  • Glad it worked! It is a bit of a culprit that it works that way when assigning a content type to a list (but I guess SP wants to keep them unique for a good reason) – Robert Lindgren Aug 8 '14 at 17:46
  • Worked - awesome. I forgot that parent of inherited was always the same. Thanks for the quick reminder. – David Sterling Mar 24 '18 at 3:13

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.