So we have added multiple publishing DBs on our system that have an error deploying template files on deployments. I have a feeling its because the "Publishing Targets" are blank. When I select them all and publish again manually everything gets pushed to the correct spots. So I am wondering if there is a script out there that can look through all these templates for the publishing target area? The screen shot below shows the area in the template that I need to find with powershell then select all checkboxes.
-
If no publishing targets are selected, Sitecore will publish to all targets by default - see item 6 on this page doc.sitecore.com/xp/en/users/102/sitecore-experience-platform/…, so you do not need to select them all for every template. How do you publish templates during deployments? It is possible that your automated deployment publish tool uses only the default "Internet" target.– Anna GevelApr 1, 2022 at 6:14
1 Answer
You can do something like the below using the PowerShell
script.
$path = "." # provide the path from where you want to start like a template
$root = Get-Item $path
$items = Get-ChildItem -Recurse . -WithParent |
Where-Object { $_.Fields["__Enable item fallback"] -ne $null } |
ForEach-Object {
$_.Editing.BeginEdit()
$_.Fields["__Publishing groups"].Value = "{8E080626-DDC3-4EF4-A1D1-F0BE4A200254}"; # Put the raw value here.
$_.Editing.EndEdit()
}
First, you need to check all the checkboxes, that you have in the Publishing target
field, and then get the raw value and put it into the above script.
Thanks