At 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”]
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 |
if (Get-PSSnapin Citrix.XenApp.Commands -ea 0) { Write-Host "Citrix.XenApp.Commands snapin already loaded" -ForegroundColor Yellow } else { if (Get-PSSnapIn "Citrix.XenApp.Commands" -registered -ea 0) { Write-Host "Loading Citrix.XenApp.Commands snapin..." -ForegroundColor Yellow Add-PSSnapin "Citrix.XenApp.Commands" } } Function Global:Get-CtxCommand { param([string[]] $Name = "*") Get-Command $Name -CommandType Cmdlet, Function ` -Module Citrix.XenApp.Commands | Sort Noun, Verb | Out-Host -Paging } Get-XASession -ComputerName CTX001 -Farm | where { $_.Protocol -eq "Ica" -and $_.State -eq "Active" -and $_.ClientName -ne $null } | Format-List -Property ClientName,AccountName| Out-File DuplicateComputerNames.txt |
[/codesyntax]
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.
Kees Baggerman
Latest posts by Kees Baggerman (see all)
- Nutanix AHV and Citrix MCS: Adding a persistent disk via Powershell – v2 - November 19, 2019
- Recovering a Protection Domain snapshot to a VM - September 13, 2019
- Checking power settings on VMs using powershell - September 11, 2019
- Updated: VM Reporting Script for Nutanix with Powershell - July 3, 2019
- Updated (again!): VM Reporting Script for Nutanix AHV/vSphere with Powershell - June 17, 2019