Saturday, May 3, 2014

Archive Log Files with Sitecore PowerShell Extensions

The other day I was talking to Mike Reynolds (@mike_i_reynolds) about his idea of a FileWatcher for the Sitecore CMS log files. That sounded like a great opportunity to use the Sitecore PowerShell Extensions module found on the Sitecore Marketplace.

The process can be broken down into these few steps:

  1. A scheduled task to run a script
  2. The script zips up the log files and saves to an archive folder
Below are the scripts to get the job done.

I added the Compress-Archive script here: /sitecore/system/Modules/PowerShell/Script Library/Functions/Compress-Archive
I then added the Archive Logs script here: /sitecore/system/Modules/PowerShell/Script Library/Tasks/Archive Logs

Finally, I created the scheduled task using the PowerShellScriptCommand.
You'll notice here that I'm using a custom field for the Task Scheduler so it's easier to see what's configured.

These scripts should be included in a future build of Sitecore PowerShell Extensions but feel free to start using now!

No comments:

Post a Comment