Skip to content

Instantly share code, notes, and snippets.

@harshbaid
Created February 22, 2024 15:16
Show Gist options
  • Save harshbaid/ec2d2817a6b6b8882e651f443ea0c13e to your computer and use it in GitHub Desktop.
Save harshbaid/ec2d2817a6b6b8882e651f443ea0c13e to your computer and use it in GitHub Desktop.
Bulk operation to reset specific field on template standard values
$baseTemplateId = "{20427F7C-8B5E-4799-A282-05376D978999}"
function IsTemplateStandardValue([Sitecore.Data.Items.Item]$item)
{
$flag = $false
$hasScriptTemplate = Test-BaseTemplate -Item $item -Template $baseTemplateId
if ($hasScriptTemplate -and $item.Name -eq "__Standard Values")
{
$flag = $true
}
return $flag
}
New-UsingBlock (New-Object Sitecore.Data.BulkUpdateContext) {
$path = '/sitecore/templates/CLIENTNAME/Features/Pages'
Reset-ItemField -Path "master:/sitecore/templates/CLIENTNAME/Features/SEO/Page speed/ScriptsAndStyles/__Standard Values" -Name "ScriptStyleLinks"
Get-ChildItem -Path master:$path -Recurse | Where-Object { IsTemplateStandardValue($_) -eq $true } | ForEach-Object { Reset-ItemField $_ -Name "ScriptStyleLinks" }
Reset-ItemField -Path master:/sitecore/content/Websites/CLIENTNAME/home -Name "ScriptStyleLinks"
Write-Host "Completed running!"
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment