<#
This script will remove old versions of items in all languages so that the items only contains a selected number of versions.
>
dialogProps = @{
Parameters = @(
@{ Name = "item"; Title="Branch to analyse"; Root="你的节点路径"},
@{ Name = "count"; Value=10; Title="Max number of versions"; Editor="number"},
@{ Name = "remove"; Value=$False; Title="Do you wish to remove items?"; Editor="check"}
)
Title = "Limit item version count"
Description = "Sitecore recommends keeping 10 or fewer versions on any item, but policy may dictate this to be a higher number."
Width = 500
Height = 280
OkButtonName = "Proceed"
CancelButtonName = "Abort"
}
$result = Read-Variable @dialogProps
if($result -ne "ok") {
Close-Window
Exit
}
item.ID -Language * | ForEach-Object { ) + @((.Versions.Count -gt ritems = @()
webVersion = Get-Item -Path web: -ID .Language
if (minVersion = count
.ID -Language .Version.Number -le remove) {
ritems.Count
| Remove-ItemVersion
}
Show-Alert "Removed reportProps = @{
Property = @(
"DisplayName",
@{Name="Version"; Expression={_.ItemPath}},
@{Name="Language"; Expression={count versions</b>."
}
$ritems | Show-ListView @reportProps
}
Close-Window