PowerShell : RePublish Content type

Introduction
 
According to Microsoft, A content type is a reusable collection of metadata (columns), workflow, behavior, and other settings for a category of items or documents in a Microsoft SharePoint Foundation 2010 list or document library. Content types enable you to manage the settings for a category of information in a centralized, reusable way.

Here I'm assuming that you have content type hub already setup at your end. For more information on how to setup content type hub please find this link ( http://sharepoint-community.net/profiles/blogs/understanding-content-type-hub-cth-in-sharepoint-2013 ).
 
Information :
 
Please find below is the powershell script which will help you publish the content type.  
  1. $CTHubURL = "{<Content Type Hub Setup URL>E.g. http://mySharePointSite :1111/}"  
  2.     #Get Content Type site and web objects  
  3.     $ctHubSite = Get-SPSite $CTHubURL  
  4.     $ctHubWeb = $ctHubSite.RootWeb  
  5.  
  6.     #Check the site is a content type hub  
  7.     if ([Microsoft.SharePoint.Taxonomy.ContentTypeSync.ContentTypePublisher]::IsContentTypeSharingEnabled($ctHubSite))  
  8.     {  
  9.         #Set up ContentTypePublisher object to allow publishing through the Content Type Hub site  
  10.         $spCTPublish = New-Object Microsoft.SharePoint.Taxonomy.ContentTypeSync.ContentTypePublisher ($ctHubSite)  
  11.          
  12.         #Step through each content type in the content type hub  
  13.         $ctHubWeb.ContentTypes | Sort-Object Name | ForEach-Object {  
  14.              
  15.             #Has the content type been published?  
  16.             if ($spCTPublish.IsPublished($_))  
  17.             {  
  18.                 #Republish content type  
  19.                 $spCTPublish.Publish($_)  
  20.                 write-host "Content type" $_.Name "has been republished" -foregroundcolor Green  
  21.             }  
  22.             else  
  23.             {  
  24.                 write-host "Content type" $_.Name "is not a published content type"  
  25.             }  
  26.         }  
  27.     }  
  28.     else  
  29.     {  
  30.         write-host $CTHubURL "is not a content type hub site."  
  31.     }  
  32.     #Dispose of site and web objects  
  33.     $ctHubWeb.Dispose()  
  34.     $ctHubSite.Dispose() 
Ebook Download
View all
Learn
View all