Connect with us

Hi, what are you looking for?

Citrix XenApp

Combating Citrix application sprawl using the XenApp SDK, Powershell, IIS, HTML, and a tiny bit of web design

One of the biggest challenges you will face in a large XenApp environment is application sprawl. With multiple farms and many Citrix admins managing different business units, the problem gets compounded. No one person knows what applications are published and to what security groups without having to hunt for it.

I’ve used a lot of 3rd party applications for monitoring and reporting on XenApp but none of them quite showed the information I wanted in an easily digestible format. So I created a solution using the XenApp SDK, Powershell, and IIS. I wanted to create nicely formatted HTML reports with all the application details and have them available via a website URL so anyone can take a look at it whenever they needed to. My audience could be a Citrix admin, an IT manager, a security department, or even a compliance auditor. I wanted the info at our fingertips and be fully automated and up to date. Think of it as a dashboard view into your Citrix environment.

So let me show you how I did it.

1. Download the XenApp 6.5 SDK. XenDesktop 7 has an SDK as well but I haven’t played with it yet. You can get the XenApp 6.5 SDK here:

http://community.citrix.com/display/xa/XenApp+6.5+Powershell+SDK

2. Install it on a XenApp server in your farm that will be running your scheduled report. You may need to disable remote signing by the way. Just open up Powershell and type:

3. Hit Start > All Programs > Citrix > XenApp 6.5 Server SDK > Windows PowerShell with Citrix XenApp 6.5 Server SDK

4. You’ll notice Powershell will start and automatically add the XenApp snapins.

5. Create a folder on the server called “CitrixDashboard” and created a “xenapp-farm-1-report.ps1” file. Open it in Notepad and copy my script in and save it. You’ll want to create a customized script for each of your farms so edit as necessary:

If the code above runs off the page, either select all of it and paste to Notepad or here it is in a .txt file you can open. Just right click-save as to your desktop and open it:

citrix-dashboard-script.txt

6. To break the script down:

-The first 3 lines add the Citrix powershell snap-ins
-The next block of lines creates the HTML formatting and saves it in variables. Change the colors and formatting to whatever you like.
-The next bit of code performs the query, grabs the data from the farm, and converts it to HTML passing the variables we declared above. It then finally saves it as an htm file.

The result of the .htm file will be something like this:

1

Get-XAApplicationReport can pull a ton of stuff from your farm. For example I sometimes use ClientFolder to see where an app is published for the user as opposed to just FolderPath which is what you see in AppCenter.

7. Now install IIS or use an existing IIS server if you have one. If you choose another server, create a share where your Citrix servers can dump their generated .htm files. You will need to tweak your .ps1 with a UNC path to this share instead of a local drive. It works great with UNC paths by the way. I have them running all over the place and dumping into a central folder on my IIS box.

8. Schedule the reports. Go to Task Scheduler on one of your XenApp servers in each farm and create a basic task. The settings you want:

Action = Start a program
Program/script = powershell.exe
Add arguments = -executionPolicy unrestricted -file "D:\CitrixDashboard\xenapp-farm-1-report.ps1"
Start in = D:\CitrixDashboard

Have it run early every morning and under a service account with farm access so it can read and enumerate the apps.

9. Create a splash page for your dashboard. The reports themselves are formatted pretty decently but it’s hard to give them a really modern look without CSS. I like to have a splash page where my users can select the farm report and also have a little information about each farm. My splash page looks like this to give you an idea. Trust me, it’s a lot slicker looking in person. Plenty of cool mouseovers, rollovers, etc. I like to use subdued colors for inactive items. Whatever is active, I like to have a nice bold strong color (which unfortunately I can’t capture and convey to you with just a single screenshot). Just keep it simple and flowing and your users will love it:

2

I recommend using http://colorschemedesigner.com or http://www.colorhexa.com to help pick your color scheme/palette if you’re design challenged. Most larger companies will have a marketing department that puts out a branding guide. See if you can get a hold of that and get the exact hex values of the company colors. There are also plenty of free personal/commercial usage HTML/CSS templates out there if you want to modify one for your purposes.

UPDATE: I’ve gotten a lot of good emails about my script. One question asked was how to get it working on older farms like Presentation Server 4.0. Check out Stan Czerno’s MFCOM based VBscript to pull in the farm details. You can modify what data it returns, the formatting, and export in html so it matches your powershell script:

http://www.czerno.com/default.asp?inc=/html/citrix/scripts/PubAppReportexcel.asp

Big thanks to Stan for creating this awesome script!

8 Comments

8 Comments

  1. Daniel Ruiz

    October 10, 2013 at 7:26 AM

    This is great… appreciate sharing it. Working with web developers to make it look really great. Will share once it is done.

    Daniel

  2. Jason Samuel

    October 18, 2013 at 1:09 AM

    @Daniel Ruiz

    Glad to help Daniel! I would love to see how it comes out.

  3. Angelo

    December 16, 2013 at 7:59 AM

    Hi Jason,
    Which part of the script need I to change, to work in my environment?
    Thanks for your efforts.
    Angelo

  4. Jason Samuel

    December 16, 2013 at 10:09 AM

    @Angelo

    You shouldn’t have to change anything in the script unless you want to change the formatting and fields it pulls.

  5. Lance

    February 10, 2014 at 9:23 AM

    I am getting an error when I try to run this script. Any ideas what is wrong? The only thing I modified was the path to save the report to.

    Missing ‘)’ in method call.
    At C:\scripts\ApplicationReport.ps1:14 char:110
    + Get-XAApplicationReport * | select DisplayName, FolderPath, ApplicationType, @{n=?Servers?;e={[string]::join( <<<< ?
    ; ?, $_.ServerNames)}}, @{n="WorkerGroups";e={[string]::join(" ; ", $_.WorkerGroupNames)}}, @{n=?Users?;e={[string]::jo
    in(? ; ?, $_.Accounts)}} | Sort-Object FolderPath | ConvertTo-HTML -PreContent $PreText -head $BodyText -title "XenApp
    Published Applications – xxxxxxxxx Farm" -body "XenApp Published Applications – xxxxxxxxx Farm” -PostContent $
    PostText | Out-File C:\Temp\xenapp-xxxxxxxxx.htm
    + CategoryInfo : ParserError: (CloseParenToken:TokenId) [], ParseException
    + FullyQualifiedErrorId : MissingEndParenthesisInMethodCall

  6. Magnus

    December 24, 2014 at 8:23 AM

    Jason
    Great Article and script, can you share the splash page that you show in the above?

    Magnus

  7. Tom K.

    July 24, 2015 at 8:50 AM

    Yes, I’d like to echo the last comment above from Dec. 2014:
    Can you please share the splash page that you show in the above? That would be a nice finishing touch to this extremely helpful info,

  8. Jason Samuel

    July 27, 2015 at 9:47 AM

    Glad it works for you! Unfortunately I can’t post the exact code for the splash page as it was done for a client. But I can recommend a few websites that offer one page HTML templates you can use that offer free commercial/personal use licenses:

    https://onepagelove.com/templates/html-templates

    http://www.designsave.net/2014/07/best-free-responsive-admin-dashboard-templates.html

    http://www.scratchinginfo.net/metro-style-html-templates/

    You can also Google for “one page html template tiles” and find many more. All you need to do is hyperlink each “tile” back to your reports from the single HTML splash/landing page. My advice, make sure the template you use is Responsive so it renders well on mobile devices.

Leave a Reply

Your email address will not be published. Required fields are marked *

You May Also Like

Apache

Today I would like to go over proper URL redirection when using SSL but first I would like to preface this by describing what...

Citrix Workspace

You can use FIDO2 hardware security keys plugged into your physical desktop over the Citrix HDX remoting protocol for use with virtualized Windows Desktop...

Exchange 2003

A useful Exchange 2003 guide I wrote for a friend’s blog originally but I am posting it here on mine now for your viewing...

Apache

In a worst case scenario and all your web servers have failed, what do you do? You could have a standby group of servers...

JasonSamuel.com began in 2008 as a way for me to give back to the IT community. This website features the latest news and how-to's on enterprise mobility, security, virtualization, cloud architecture, and other technologies I work with. This website has evolved over time to become a go-to reference hub for these technologies. It receives hundreds of thousands of unique visitors from all over the world each month. More details on the About Me page.
Copyright © 2008-2023 JasonSamuel.com