Skip to main content


Update $name of Existing Items using PowerShell

Extending General Link for Experience Editor Mode in Sitecore

Welcome to our latest blog post, where we dive into the realm of PowerShell scripting to empower you to efficiently update existing items. In today’s fast-paced digital landscape, the need to manage and modify data swiftly and accurately is more crucial than ever. Whether you’re a seasoned IT professional or just starting your journey into automation, PowerShell proves to be a formidable tool.

In this guide, we’ll explore how to leverage PowerShell to seamlessly update the $name of existing items. Unlock the potential to streamline your processes, enhance productivity, and maintain control over your data. Join us on this journey as we uncover the power and versatility of PowerShell scripting for effective item updates.


I have a template, and 50-page items already exist related to template type A. Now I have a requirement to add one more field for template A with the default value ‘$name’ into the standard value of this template.

If I’m going to create any new page item related to template A, then it’s working fine. But for the already existing 50-page item field added, the field value is still showing ‘$name’ instead of being replaced with the page item’s name.

The following is the essential PowerShell parameter that we are using:


Prompts the user to provide values for variables required by the script to perform its operation. If a user selects the “OK” button, the command will return ‘ok’ as its value. If a user selects the “Cancel” button or closes the window with the “x” button at the top-right corner of the dialog, the command will return ‘cancel’ as its value.

Read-Variable [-Parameters <Object[]>] [-Description <String>] [-CancelButtonName <String>] [-OkButtonName <String>] [-ShowHints <SwitchParameter>] [-Validator <ScriptBlock>] [-ValidatorParameters <Hashtable>] [-Title <String>] [-Icon <String>] [-Width <Int32>] [-Height <Int32>] [<CommonParameters>]


The input type is the type of the object that you can pipe to the cmdlet.

  • Sitecore.Data.Items.Item


The output type is the type of the objects that the cmdlet emits.

  • System.String


You can use the PowerShell script below to update the values of your field, or you can download or copy-paste the PowerShell script from this link. You have to replace Your field name with the field you need to change.

$dialog= Read-Variable -Parameters `
@{ Name = "media"; Title = "Path"; Root="/sitecore/"; Editor="item";Tab="General";},
@{ Name = "contentType"; Title = "Content Type"; Root="/sitecore/templates"; Editor="item";Tab="General";} `
-Description "This script will edit field value " `
-Title "Field Value Update" -Width 500 -Height 500 `
-OkButtonName "Proceed" -CancelButtonName "Abort"
if ($dialog -ne "ok")
cd $media.Paths.FullPath;
$templateId = $contentType.ID;

Write-Host "Process Starting";
Get-ChildItem -Recurse -Language * . |  ForEach-Object {
$this = $_
if($_.TemplateID -eq $templateId){     
if($_.Fields["Your field name"].Value -eq '$name')
             $_['Your field name']=$_.Name;
Write-Host "Process Completed";

Let’s See How it Works

Update $name Of Existing Items


We hope this helps! Check out our Sitecore blog for more helpful tips and tricks.

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.

Ankit Tawale

Ankit Tawale is a Senior Technical Consultant at Perficient based in Nagpur. He is a Sitecore Certified Developer with experience in Sitecore, SXA, JavaScript, CSS, and .Net MVC. He is passionate about discovering new technology and understanding the architecture that supports them.

More from this Author

Follow Us