Hi,
Today I’ll present an easy way to republish all the content types that are in a hub, this idea came because a customer wants to change the url of the App web, so I recreate it the App web, and the last step was to republish all the content type to restore the content of the portal as was before the change.
function Republish-HubContentTypes ($CTHubURL) { #Get Content Type site and web objects $ctHubSite = Get-SPSite $CTHubURL $ctHubWeb = $ctHubSite.RootWeb #Check the site is a content type hub if ([Microsoft.SharePoint.Taxonomy.ContentTypeSync.ContentTypePublisher]::IsContentTypeSharingEnabled($ctHubSite)) { #Set up ContentTypePublisher object to allow publishing through the Content Type Hub site $spCTPublish = New-Object Microsoft.SharePoint.Taxonomy.ContentTypeSync.ContentTypePublisher ($ctHubSite) #Step through each content type in the content type hub $ctHubWeb.ContentTypes | Sort-Object Name | ForEach-Object { { #Republish content type $spCTPublish.Publish($_) write-host "Content type" $_.Name "has been republished" -foregroundcolor Green } $ctHubWeb.Dispose() $ctHubSite.Dispose() } } } Republish-HubContentTypes –CTHubURL "ContentTypeHubURL"
Hope that helps!