I have a powershell script (thanks to this link).
My environment: SP 2013. Content type created on root, but want to use in only one subsite.
It looks like given below and set content type = true (if not) and add the content type. But this is for the whole site collection.
I want it to run in the subsite called "DocCentre" only and add the content type in that subsite's libraries as default content type. How can I accomplish that?
> #Get site object and specify name of the content type to look for in each library $site = Get-SPSite http://<site> $lookForCT = "Sales
> Document"
>
> #Walk through each site in the site collection $site | Get-SPWeb -Limit all | ForEach-Object {
>
> write-host "Checking site:"$_.Title
>
> #Go through each document library in the site
> $_.Lists | where { $_.BaseTemplate -eq "DocumentLibrary" } | ForEach-Object {
>
> write-host "Checking list:"$_.Title
> $_.ContentTypesEnabled = $true
>
> #Check to see if the library contains the content type specified
> #at the start of the script
> if (($_.ContentTypes | where { $_.Name -eq $lookForCT }) -eq $null)
> {
> write-host "No content type exists with the name" $lookForCT "on list" $_.Title
> }
> else
> {
> #Add site content types to the list
> $ctToAdd = $site.RootWeb.ContentTypes["HR Document"]
> $ct = $_.ContentTypes.Add($ctToAdd)
> write-host "Content type" $ct.Name "added to list" $_.Title
> $ctToAdd = $site.RootWeb.ContentTypes["IT Document"]
> $ct = $_.ContentTypes.Add($ctToAdd)
> write-host "Content type" $ct.Name "added to list" $_.Title
> $_.Update()
> }
> } } #Dispose of the site object $site.Dispose()