In SitecoreAI CMS (FKA XM Cloud), you have the ability to add PowerShell scripts, which is a great way to enhance functionality and run commands that you might have run in other ways in "legacy" Sitecore. You pretty much have the full run of the content and command structures, though you'll have to dig for it sometimes. A good reference can be found at the Sitecore PowerShell site.
This also allows you to set up PowerShell scripts that can be run as a scheduled task in Sitecore. For example, I have a script that scans recently update taxonomy values, and if anything changed, it finds the related items connected to it and publishes them, so the values are updated in Sitecore Search. But I found that after setting up my script and my task, the task would run but the script wouldn't fire.
I didn't see this in the documentation directly, but I did find the cause in an AI search about the topic. To get the task to fire the script, the script item has to be in a specific area of the tree structure, but then you'll find that the structure isn't fully in place. To set it up:
- Go to the /sitecore/system/Modules/PowerShell/Script Library/SPE/Maintenance folder.
- Create a folder called "Scheduled Tasks" - the name is the important thing here.
- Place your script in this folder.
- Set up your scheduled task with the PowerShell Scripted Task Schedule insert option and choose your script.
The key is the script location. My enhancement suggestion to Sitecore would be to add the "Scheduled Tasks" folder to their default IAR setup, but you can easily add it to your own. Again, it's the name that matters, not the item template, ID, or the like.
I hope this helps you out in getting your scheduled tasks going!
Top comments (0)