C# Corner
Tech
News
Videos
Forums
Trainings
Books
Events
More
Interviews
Jobs
Live
Learn
Career
Members
Blogs
Challenges
Certifications
Bounties
Contribute
Article
Blog
Video
Ebook
Interview Question
Collapse
Feed
Dashboard
Wallet
Learn
Achievements
Network
Refer
Rewards
SharpGPT
Premium
Contribute
Article
Blog
Video
Ebook
Interview Question
Register
Login
PowerShell Script - Republish Content Type
WhatsApp
Ketak Bhalsing
May 20
2016
859
0
0
$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()
Content Type Hub
PowerShell
SharePoint
Up Next
PowerShell Script - Republish Content Type