Tagged: template

Bulk update fields using SPE

I came across a scenario, where I need to update the email field for all custom forms built with ‘EmailTemplate’. Since it’s going to be a bulk update, decided to do it in SPE(so powerful!)

Here is the script I wrote –

$path = "master:/sitecore/content/external_forms"
$templateName = "EmailTemplate"
$emailAddresses = "test@test.com"
$fieldName = "ToEmail"
$items = Get-ChildItem Path $path Recurse | Where-Object { $_.TemplateName -eq $templateName }
foreach($item in $items) {
if($item.Fields[$fieldName] -ne 'null'){
$item.Editing.BeginEdit()
$item.Fields[$fieldName].Value = $emailAddresses
$item.Editing.EndEdit()
Write-Host ($item.Name + ": " + $item.Fields[$fieldName].Value)
}
}

Hope this helps someone. Any questions, please leave a comment.

Happy Sitecoring!

0