SharePoint Stack Exchange is a question and answer site for SharePoint enthusiasts. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

Is there a way to add the "Link to Document" content type to all existing document libraries in a site/site collection other than editing each one manually? I'm fine to do it with PowerShell if there is a way.

Also is there a way to change the template for the default document library so that all new document libraries will have this functionality?

share|improve this question

This is untested, but I'd probably do something like this:

$site = get-spsite http://your/site

$rootWeb = $site.RootWeb

$linkToDocCType = $rootWeb.AvailableContentTypes["Link to a Document"]

foreach ($web in $site.AllWebs)
    foreach ($list in $web.Lists)
        if ($list.BaseType -eq [Microsoft.SharePoint.SPBaseType]::DocumentLibrary)
            $listMatchCTypeId = $list.ContentTypes.BestMatch($linkToDocCType.Id)

            if (!$listMatchCTypeId.IsChildOf($linkToDocCType.Id))
                $webCTypeCopy = $list.ParentWeb.AvailableContentTypes[$linkToDocCType.Id]
                $listCTypeCopy = new-object Microsoft.SharePoint.SPContentType($webCTypeCopy, $list.ContentTypes, $webCTypeCopy.Name)



As far as your second question, about changing the default document library template to always include "Link to a Document", I really don't know. It may be possible, but then again it's my understanding that it's a best-practice to leave the OOB stuff alone and not customize it, as an update from Microsoft might overwrite your customization.

share|improve this answer

Your Answer


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.