Quick Tip: One CLI Command to Solve Your IAR Database Override Problems

Background
IAR has numerous benefits, but it can cause a lot of problems if you or others tinker with items that are included in your IAR dat files. This is common during development and initial golive. The end result is that you may push item changes via source control, but the changes don't take because they have been overridden in the database. This often leads to much confusion and churn when pushing fixes/changes to templates, presentation, etc.
Over the years, we've seen custom modules, tools, and scripts for identifying and cleaning up IAR items that have been overridden in the database. However, there is a single CLI command that can be used to view and remove all IAR database overrides in one line.
Prerequisites
Before running the command, make sure you have:
- The Sitecore CLI installed (
dotnet tool install Sitecore.CLI) - The itemres plugin added:
dotnet sitecore plugin add -n Sitecore.DevEx.Extensibility.ItemResource - An authenticated connection to your environment. The
-nvalue (developmentbelow) refers to an environment defined in youruser.json, so you'll need to log in first withdotnet sitecore loginbefore the command can reach the instance
The Command
The Sitecore docs outline a single command that can do everything you need to perform analysis and cleanup of IAR database overrides. The full command is:
dotnet sitecore itemres cleanup -p "/sitecore/templates/Project" -n "development" -f -r -v -wWhere:
f= forcer= recursev= verbosep= pathn= environment name (as defined in youruser.json)w= what-if
Run the what-if to see which items are overridden in the database, and then run the command without the w to remove them, scoped by path as you wish.
Approach
The parts of the tree I've seen the most issues with overrides are:
/sitecore/content/sites/ACME/Presentation/sitecore/templates/Project/sitecore/content/sites/ACME/Settings/Standard Values
I recommend running the command on these paths once in a while, especially before a golive, to ensure that your IAR items are not overridden in the database.
One Last Step
After you perform the cleanup, you may need to clear the cache, restart the instance, and/or rebuild the sitecore_master_index.
Clean your room,
-MG





