Pages

15 August, 2023

Useful Sitecore PowerShell Scripts

In this blog post, I am sharing some of the useful SPE scripts which I used in my previous project. 

Remove Sitecore Originator Field Value

Originator field indicates the branch template used to create the item. In case if the branch template is deleted, the field may be left out with orphaned GUID value. 

Either the entire content tree can be parsed whether there is any orphaned GUID in that field or use Scan the database for broken links in Sitecore Control panel. In the below script, I took the list of items with broken originator field and created an CSV with Column ID for Item ID and script will intake the excel and clear the Originator field. 


Apply random image to article pages

One of the ask is to upload a set of images in Media library and randomly apply one image to each of the article pages which are already created in Sitecore. 

First, we uploaded all the images in a folder in Media library. Then executed the below script which will randomly choose one image and apply it in each article page. We also added a step to publish the page. 

Remove Orphaned Renderings

In certain scenarios, content authors reports us to remove any orphaned renderings across the site. Though it is different between each Sitecore solutions, below code can be leveraged to build custom script and remove renderings. Thanks to Aaron Bickle who provided a starter kit for this task and was able to customize for our solution. 

Sitecore



No comments:

Post a Comment

blockquote { margin: 0; } blockquote p { padding: 15px; background: #eee; border-radius: 5px; } blockquote p::before { content: '\201C'; } blockquote p::after { content: '\201D'; }