Thursday, July 23, 2009

Publishing Citrix Reports - clean workaround

One of my chief complaints about publishing Citrix Reports using the Report Center is the lack of options when it comes to the publish folder.

By default you have the choice of Overwrite or Archive, in an archive situation (which is very common in the case of the Configuration log report) when you set in the subfolder field it ends up getting appended with an _# after the first run. This makes finding old reports near impossible (is CL_178 2/12/2009?).

I found a quick and easy workaround using a scheduled PowerShell command to solve the problem.

In my setup I have a daily Configuration Logging Specification setup to publish as follows:

This specification has a scheduled job that runs the report every night at 12:05am.

At 12:10am I have a scheduled task on the webserver (setup via the Scheduled Tasks tool) that runs this command:

rni 'D:\Inetpub\reports\ConfLogDaily\CLD' ('{0:yyyyMMdd}' -f (Get-Date).AddDays(-1))


This command renames the CLD folder to a Folder that shows up as YYYYMMDD (with the previous day as the day).

One very important note when working on Powershell Scripts that you may end up running via a cmd prompt (or scheduled task) using powershell.exe:
Double Quotes (") is your sworn enemy, though working in the Powershell command prompt Single Quote (') and Double Quotes are almost always interchangable, the Double quote causes havoc with running it via a scheduled task/regular command prompt (see below). Just something to keep in mind.

Now when I browse to the http://webserver/reports/ConfLogDaily folder instead of seeing:
CLD
CLD_1
CLD_2
*and so on*

I see:
20090101
20090102
20090103
*and so on*


One small note that when you set up your scheduled task you actually set the task up with the command line to PowerShell.exe like so:

x64
C:\WINDOWS\SysWOW64\windowspowershell\v1.0\powershell.exe rni 'D:\Inetpub\reports\ConfLogDaily\CLD' ('{0:yyyyMMdd}' -f (Get-Date).AddDays(-1))

x32

C:\WINDOWS\System32\windowspowershell\v1.0\powershell.exe rni 'D:\Inetpub\reports\ConfLogDaily\CLD' ('{0:yyyyMMdd}' -f (Get-Date).AddDays(-1))

No comments:

Post a Comment