Skip to main content

Posts

Showing posts with the label PowerShell Scripts

Copy field value from Web database to Master database using Powershell

Recently, we encountered an instance where we need to copy a particular field value from Sitecore Web database to Master database in a peculiar case.    I wrote a simple PowerShell script which did the trick. Here is the script and the same can be modified on the case to case basis. Here are the steps.  1.Filter and select the Sitecore items based on a template id for particular type of items from both master database and web database. 2. Loop through the list and find a matching item based on the item id from Master DB and Web DB. 3. Edit the match which common in both the database. $pagetempId='{349F8A57-BA39-42DD-A82F-671641D05812}' $path="/sitecore/content/MySite/Press/News" $itemsmaster=Get-ChildItem master:$path -recurse | where-object { $_.'TemplateId' -eq $pagetempId} $itemsweb=Get-ChildItem web:$path -recurse | where-object { $_.'TemplateId' -eq $pagetempId} foreach($itemweb in $itemsweb) {   foreach($itemmaster in $itemsm...