TECHNOLOGIES
FORUMS
JOBS
BOOKS
EVENTS
INTERVIEWS
Live
MORE
LEARN
Training
CAREER
MEMBERS
VIDEOS
NEWS
BLOGS
Sign Up
Login
No unread comment.
View All Comments
No unread message.
View All Messages
No unread notification.
View All Notifications
C# Corner
Post
An Article
A Blog
A News
A Video
An EBook
An Interview Question
Ask Question
PowerShell Script - Republish Content Type
Ketak Bhalsing
May 20
2016
Code
805
0
0
facebook
twitter
linkedIn
Reddit
WhatsApp
Email
Bookmark
expand
$CTHubURL =
"{<Content Type Hub Setup URL>E.g. http://mySharePointSite :1111/}"
#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 {
#Has the content type been published?
if
($spCTPublish.IsPublished($_))
{
#Republish content type
$spCTPublish.Publish($_)
write-host
"Content type"
$_.Name
"has been republished"
-foregroundcolor Green
}
else
{
write-host
"Content type"
$_.Name
"is not a published content type"
}
}
}
else
{
write-host $CTHubURL
"is not a content type hub site"
}
#Dispose of site and web objects
$ctHubWeb.Dispose()
$ctHubSite.Dispose()
PowerShell
SharePoint
Content Type Hub