Last active
May 2, 2024 14:17
-
-
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
This file contains hidden or 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
$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 |
This file contains hidden or 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
$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