Skip to content

Instantly share code, notes, and snippets.

@michaellwest
Last active May 12, 2022 01:55
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save michaellwest/309af840da11bad5fc44b532384f5331 to your computer and use it in GitHub Desktop.
Save michaellwest/309af840da11bad5fc44b532384f5331 to your computer and use it in GitHub Desktop.
Sitecore PowerShell Extensions script to rename items. Workaround for an issue in SXA where items are not published because the revision is missing on the item (even though the Content Editor shows one). Sitecore Support public reference number 522438
$matchedItems = [System.Collections.ArrayList]@()
$revisionFilter = @("9323dec0-9b37-4fae-b87c-2dc12cbea0f2")
Get-ChildItem -Path "master:\media library" -Recurse |
Where-Object { [string]::IsNullOrEmpty($PSItem["__revision"]) -or $revisionFilter -contains $PSItem["__revision"] } |
ForEach-Object { $matchedItems.Add([PSCustomObject]@{"ItemId"=$PSItem.ID; "RevisionId"=$PSItem["__revision"]; "ItemPath"=$PSItem.ItemPath}) > $null }
$matchedItems | Show-ListView
$allowedNames = @("Base Themes", "Extension Themes", "Feature", "Foundation", "Project", "Themes")
$items = Get-ChildItem -Path "master:/media library" | Where-Object { $_.TemplateId -eq "{FE5DD826-48C6-436D-B87A-7C4210C7413B}" -and $allowedNames -contains $_.Name }
foreach($item in $items) {
$name = $item.Name
$item | Rename-Item -NewName ($name + "1")
$item | Rename-Item -NewName $name
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment