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
Hi Kees,
The executionpolicy for PowerShell is something that, in my opinion, should be set by a policy and not in each script. Now you would get a message where you would have to confirm that you want to change the exectution policy.
But in case you do want this to be included in your sript, some recommendations:
To avoid that nasty confirmation message, use the -force parameter.
Set the execution policy on the leven you desire. Right now the default (LocalMachine) will be used where (i think) process or currentuser level should suffice in this case?
And last… very good idea and code 😀
Jeff.
Jeff,
I agree on setting this via GPO but sometimes you just don’t have access to these GPO’s or sys admins don’t want to set this so that’s why I’ve added the first line, thanks for the tips on the confirmation message and the execution policy level.
Regards,
Kees
If you have EdgeSight installed, you can run some queries to find the thin client devices that are connecting to your Citrix farm(s). I go into detail in this blog post: http://edgesightunderthehood.com/2011/07/06/reporting-on-non-pc-devices/
Thanks,
Alain