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!

Sunday, April 6, 2014

Sitecore Code Editor 1.4 Preview

It's raining today here in Dallas which probably explains why I sound like I'm falling asleep in the video. Here's a preview of enhancements to Code Editor 1.4.

Reports with Sitecore PowerShell Extensions

I was trolling through the Sitecore Marketplace the other day and found this cool module for reporting about media library items called Unused Media Manager. I thought this would be a great example of how you can adapt code that would traditionally be written in C# and turn it into a simple script in Powershell.

Here's a quick example of where the new scripts appear within the Sitecore tree.

As you can see, SPE provides a reports folder where you can add scripts that will appear under Reporting Tools > PowerShell Reports.

I selected the Unused media items script which produced the following results:
The above window is produced by using the "Show-ListView" command.

Wednesday, February 5, 2014

Format Excel Column for Size in GB

Today I was doing some reporting on file sizes and saw that I had columns with data in bytes. When you are looking at the length in gigabytes it can get kinda crazy.
Here's a simple trick:
Format the column with a custom setting and paste this in the format
[<500000]#,##0" B ";[<500000000]#,##0,," MB";#,##0,,," GB"

Original article here

Tuesday, January 21, 2014

Site Down for Maintenance

Here is something that I've been trying to setup as part of our deployment process. The goal is to provide users with a site maintenance page during the deployment. We do not require 100% up-time so this solution should meet our needs. I found additional details here which work pretty nice.

Steps:

  1. Copy App_Offline.htm.disabled to the website directory and move to App_Offline.htm
  2. Copy the application’s Web.config to Web.config.backup and move Web.config.disabled to Web.config, replacing the original
  3. Test that the offline page is rendered
  4. Deploy file system changes
  5. Move Web.config.backup to Web.config, replacing the temporary file
  6. Delete App_Offline.htm

Friday, January 17, 2014

Report Duplicate AD Users By EmployeeID

Note: The employeeID is formatted to 7 characters so that if you had numbers with leading 0s they would still be matched.

Tuesday, November 26, 2013

Hedgehog TDS - Package Version

I wanted to create TDS packages using the version from the project assembly version.
Here's a piece of code that I finally figured out how to accomplish dynamically. Place at the bottom of your .scproj file.