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:
1 |
set-executionpolicy unrestricted |
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:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 |
Add-PSSnapIn citrix.xenapp.commands Add-PSSnapIn citrix.common.Commands Add-PSSnapIn citrix.common.groupPolicy $BodyText = "" $BodyText = $BodyText + "BODY{font-family: verdana;font-size: small;background-color:White;}" $BodyText = $BodyText + "TABLE{border-width: 1px;border-style: solid;border-color: black;border-collapse: collapse;}" $BodyText = $BodyText + "TH{border-width: 1px;padding: 0px;border-style: solid;border-color: black; color:white;background-color:#09347a}" $BodyText = $BodyText + "TD{border-width: 1px;padding: 0px;border-style: solid;border-color: black;background-color:#d7e9f8}" $BodyText = $BodyText + "" $PreText = " Last Updated:" + (get-date) +""$PostText = " Email xxxxxxxxx@xxxxxxxxx.com with any questions or comments about this report. "Get-XAApplicationReport * | select DisplayName, FolderPath, ApplicationType, @{n=”Servers”;e={[string]::join(” ; “, $_.ServerNames)}}, @{n="WorkerGroups";e={[string]::join(" ; ", $_.WorkerGroupNames)}}, @{n=”Users”;e={[string]::join(” ; “, $_.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 D:\CitrixDashboard\xenapp-xxxxxxxxx.htm |
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:
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:
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:
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!
Jason Samuel is a visionary product leader and trusted advisor with a proven track record of shaping strategy and driving technology innovation. With extensive expertise in enterprise end-user computing, security, cloud, automation, and virtualization technologies, Jason has become a globally recognized authority in the IT industry. His career spans consulting for hundreds of Fortune 500 enterprises across diverse business sectors worldwide, delivering cutting-edge digital solutions from Citrix, Microsoft, VMware, Amazon, Google, and NVIDIA that seamlessly balance security with exceptional user experiences.
Jason’s leadership is amplified by his dedication to knowledge-sharing as an author, speaker, podcaster, and mentor within the global IT and technology community. Recognized with numerous prestigious awards, Jason’s contributions underscore his commitment to advancing technology and empowering organizations to achieve transformative results. Follow him on LinkedIn.
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
Jason Samuel
October 18, 2013 at 1:09 AM
@Daniel Ruiz
Glad to help Daniel! I would love to see how it comes out.
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
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.
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
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
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,
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.