Last active
January 3, 2016 20:55
-
-
Save arjancornelissen/5ba7dd011edd06576010 to your computer and use it in GitHub Desktop.
Blog Force renewal of Content Types
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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