Skip to content

Instantly share code, notes, and snippets.

@arjancornelissen
Last active January 3, 2016 20:55
Show Gist options
  • Save arjancornelissen/5ba7dd011edd06576010 to your computer and use it in GitHub Desktop.
Save arjancornelissen/5ba7dd011edd06576010 to your computer and use it in GitHub Desktop.
Blog Force renewal of Content Types
param
(
[Parameter(Mandatory=$true)]
[string]$siteurl,
[Parameter(Mandatory=$false)]
[bool]$OnlyThisSite
)
Function RemoveAllTimeStamps([Microsoft.SharePoint.SPSite] $site)
{
if ($site -eq $null) { return }
$rootWeb = $site.RootWeb
if ($rootWeb.Properties.ContainsKey("MetadataTimeStamp"))
{
$rootWeb.Properties["MetadataTimeStamp"] = [string]::Empty
$rootWeb.Properties.Update()
}
}
$Host.UI.RawUI.WindowTitle = "Set Renewal for content types"
if($onlyThisSite)
{
$site = Get-SPSite $siteurl
RemoveAllTimeStamps $site
$site.Dispose()
}
else
{
$webApp = Get-spWebApplication $siteurl
$total = $webApp.Sites.Count
$counter = 0
$webApp.Sites | % {
$site = $_
$Host.UI.RawUI.WindowTitle = "Set Renewal for content types $counter / $total"
RemoveAllTimeStamps $site
$site.Dispose()
$counter++
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment