Get duplicate client hostnames from XenApp with Powershell

powershellAt one of my current projects we’ve encountered the situation were people had non domain joined machines (corporate owned), those machines were deployed via an external deployment mechanism but we discovered that a lot of the machines had duplicate hostnames. Not a big deal as the machines weren’t domain joined but whilst the customer wanted to use Intune to manage these devices it could become complicated as Intune displays the hostname of the machine.

These machines are being used to access the centralized published desktop via XenApp 6.5 so all the connected machines would display their hostname and current user in the XenApp management console. To get the combination of client hostname and username from the Citrix XenApp datastore I wrote a small Powershell script based on the Citrix XenApp 6.5 SDK which includes remoting:

[codesyntax lang=”powershell” lines=”normal” container=”none”]



After running this script I would get a text file containing the username and clientname from all active ICA sessions on the XenApp farm. The format was displayed as:

ClientName : LT001
AccountName : Contoso\k.baggerman

I imported the output from the powershell script (text file) into Excel and deleted the empty rows by using the following instruction:

  • Select your data
  • Press F5
    This opens “Go to” dialog in Excel. Now hit on that “select” button.
  • From “select special” screen, select “Blanks” (shown aside)
    Now, all the blank cells will be selected.
  • Just press CTRL and Minus sign (-)
  • Select “shift cells up” or “entire row” as needed.

As the empty rows were removed now I did a formatting on the excel sheet to import the data as two separate rows. With some help of Conditional formatting I was able to display the duplicate records and create a list of duplicate systems including the users that used that machine so we were able to pinpoint the users with machines with a duplicate name.

The following two tabs change content below.

Kees Baggerman

Kees Baggerman is a Staff Solutions Architect for End User Computing at Nutanix. Kees has driven numerous Microsoft and Citrix, and RES infrastructures functional/technical designs, migrations, implementations engagements over the years.

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.