Citrix: Powershell script to list active thin clients
I was working on a project and one of the sys admins wanted to display which thin clients where logged on, so we made a powershell script to export all active thin clients to a txt file. He could make a script that would enumerate that txt file into HTML to display the occupied thin clients on a screen at the entrance so employees could determine which client they could use that day.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 |
set-executionpolicy remotesigned 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 -Farm | where { $_.Protocol -eq "Ica" -and $_.State -eq "Active" -and $_.ClientName -ne $null -and $_.ClientName -like "TCL*" } | Format-List -Property ClientName | Out-File \\servername\sharename\ActiveTCs.txt |
Here’s the script, it’s pretty straight forward: It gets the Citrix.XenApp.Commands snapin if it’s not already in place and lists the information based on active ICA sessions and the only when the client name starts with TCL (Thin Client names based on the naming conventions for this customer).
Output is as following:
ClientName : TCL0004
ClientName : TCL0003
ClientName : TCL0001
ClientName : TCL0002
ClientName : TCL0008
I can’t published the script to enumerate the txt file as it contains to much customer details but I’m sure this is a good start to create the same interface for your users. In this case we used RES Automation Manager to run the script every 5 minutes so employees would know where they could work.
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
3 comments