XenApp 6.5 Application Reporting

Posted: December 6, 2013 in Citrix
Tags: , , , , , , , , ,

At one point, my boss had asked me for a list of who had remote access through our Citrix servers.  We have XenDesktop 5.6 & XenApp 6.5, but we don’t allow access to the XD machines, so, I had 1/2 my battle done.

Now the first time, I did it by hand, since I didn’t have a lot of time to figure out how to do it.  That was fine and dandy for a while, but my boss came back and asked me to refresh it.  Ok, so now I have a pattern, and it’s highly likely I’ll have to do it again at some point, so time to automate it.

In the past, I had written a pretty extensive MFCOM script to document XenApp 4.5/5.0 farms.  But, since we have XA 6.5, MFCOM wasn’t an option.  I started digging into the XA 6.5 SDK, and going through the powershell cmdlets.  I installed the SDK, and found out that it was built on powershell remoting.  I’m not strong on powershell remoting yet, so, the SDK was not much use without being on one of the servers (at least until I spend some time learning the remoting).

Most of the naming of the cmdlets looks very straightforward, and Citrix does follow Microsoft’s recommendation about putting initials in their commands to distinguish them.  All of the nouns for the commands start with xa.   The most obvious promising cmdlet was get-xaapplication.  One of the primary things about powershell is the discoverability.  So, the first thing to do was load the snapin, and run the get-help command.  I ran a quick help get-xaapplication -full. (As a side note, a while back I took Don Jones’ advanced powershell class, and it was fantastic.  In this class I learned about using the help command – it not only shows you help like get-help, it also paginates the help output – similar to more.exe or piping to out-host -paging.)

NAME
 Get-XAApplication

SYNOPSIS
 Retrieves the published applications in the farm.

SYNTAX
 Get-XAApplication [[-BrowserName] <String[]>] [-LocalhostOnly] [-ComputerName <String>] [<CommonParameters>]

 Get-XAApplication -FolderPath <String[]> [-LocalhostOnly] [-ComputerName <String>] [<CommonParameters>]

 Get-XAApplication -ServerName <String[]> [-SessionId <Int32[]>] [-LocalhostOnly] [-ComputerName <String>] 
 [<CommonParameters>]

 Get-XAApplication -WorkerGroupName <String[]> [-LocalhostOnly] [-ComputerName <String>] [<CommonParameters>]

 Get-XAApplication -FileTypeName <String[]> [-LocalhostOnly] [-ComputerName <String>] [<CommonParameters>]

 Get-XAApplication -AccountDisplayName <String[]> [-LocalhostOnly] [-ComputerName <String>] [<CommonParameters>]

 Get-XAApplication -LoadEvaluatorName <String[]> [-LocalhostOnly] [-ComputerName <String>] [<CommonParameters>]

 Get-XAApplication -InputObject <XAApplication[]> [-LocalhostOnly] [-ComputerName <String>] [<CommonParameters>]

Looks promising.. Fortunately for us, our external applications are collected together in a folder tree called external.  So, I tried get-xaapplication -folderpath external. That threw an error.  So, now I tried get-xafolder.  That turned up multiple folders:

FolderPath
----------
Applications
Servers
WorkerGroups

So, it was definitely interesting that it picked up the Applications node from the tree in AppCenter.  So, I tried get-xaapplication -folderpath applications/external.  I got the list of applications I was expecting.  The next thing was to see what properties were available. So, rather than typing it all again (with the expectation I’d be typing it a lot more, I set a quick $test = get-xaapplication -folderpath applications/external.  Another key option for discoverability – the get-member command.  The command shows the properties of the object.  $test | get-member.  I started looking at the properties. But, a critical item was missing – no trace of the user accounts?

A little internet research turned up that I needed the get-xaapplicationreport command.  The internet research turned up the idea of piping the get-xaapplication into the get-xaapplicationreport command.  I combined it all to see what I got from it.

PS C:\> Get-XAApplication | Get-XAApplicationReport | get-member

I found a property I was looking for – Accounts.. So the next step was to do the same command but instead of ending with get-member, I used format-list *.  This puts all the properties in a list, and shows you what the data actually is.  Accounts definitely contained the data I was looking for. Now it was time to get more detailed.  So, this time, I took a specific application.

$test = Get-XAApplicationReport -BrowserName notepad

Now, I just accessed the properties for $test.  $test.accounts provided a list of the user accounts and group accounts assigned to the application. But, it turned up several key properties: AccountName, AccountID, AccountType.  But, I still did not want to do this manually, or with a lot of in between steps.  I could find what I needed, and it was time to find a better way to handle this.  And I’ll cover that in the next post.

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s