Client side XENAPP Session enumeration and selective logoff based on XenApp Server using ICA Client Object (WFICALib)

In my previous post i used AutoIt script to achieve this and now finally figured out to do it using ICA Client Object (WFICALib)
[code language=”powershell” title=”PowerShell Script”]
#the following keys need to be set on 32bit machine; for x64 use wow6432node.
#HKLM\Software\Citrix\ICA Client\CCM\AllowLiveMonitoring=1 (DWORD 32)
#HKLM\Software\Citrix\ICA Client\CCM\AllowSimulationAPI=1 (DWORD 32)
#Use Program Files (x86) for x64 bit machines
[System.Reflection.Assembly]::LoadFile("C:\Program Files\Citrix\ICA Client\WfIcaLib.dll")
$ICO = New-Object WFICALib.ICAClientClass
$ICO.OutputMode = [WFICALib.OutputMode]::OutputModeNormal
$EnumHandle = $ICO.EnumerateCCMSessions()
$NumSessions = $ICO.GetEnumNameCount($EnumHandle );
#"Number of live CCM sessions are:" + $NumSessions.tostring()
for( $index = 0; $index -lt $NumSessions ;$index++)
$sessionid = $ICO.GetEnumNameByIndex($EnumHandle, $index)
$APPSERVER = $ICO.GetSessionString(0)
if($AppSERVER -match "XA-WIN2K8-EPIC*")
"EPIC Session Found running on $AppSERVER; logging off"
[code language=”text” title=”References” light=”true” collapse=”true”]
ICA Client Object Changes in the Version 11.2 XenApp Plug-in
ICA Client Object Reference Guide version 2.5, see:

ICA connections using Powershell – Part 3


Join the Conversation


  1. This is exactly what we was looking for! You really saved our bacon this time Smulpy! To avoid setting the registry keys we ended up executing the ica file inside our application using the LoadIcaFile() and Connect(). This allowed us to later Logoff() the session which was our initial headache. Keep up the good work and keep sharing.

Leave a comment

Your email address will not be published. Required fields are marked *

WordPress Appliance - Powered by TurnKey Linux