Since version 10.x of the ICA Client, Citrix has shipped the ICA Client Object (ICO) SDK with the installation. This allows developers to control the ICA Client. Writing managed code using ICO is a breeze (my ICAConnect tool is using it), but you can easily write Powershell scripts which leverage the SDK.
The ICOSDK is accessible by using a DLL called “WfIcaLib.dll”, which is located in your ICA Client (or Citrix Receiver) installation directory (default is “%ProgramFiles%\Citrix\ICA Client” on 32bit platforms and “%ProgramFiles(x86)%\Citrix\ICA Client” on 64bit platforms). Now let’s have some fun with the ICO SDK using Powershell.
First of all, we need to start up Powershell to start working. Since the ICO SDK is a 32bit DLL, we need to start Powershell in x86 mode (this is only valid if you’re using a 64bit Operating System). Press Start > Accessories > Windows PowerShell > Windows PowerShell (x86). Note that it should display “Windows PowerShell (x86)” in the PowerShell window.
Ok, now it’s time to load the ICO SDK library into Powershell. This can be done by executing the following command:
Note that I’m using a 64bit Operating System, so I’m pointing to “Program Files (x86)”, if you’re using a 32bit Operating System, you should point to “Program Files”. Now Powershell should display something like this:
Setting the password for the ICA connection can’t be done through a property, instead you will have to use the SetProp() method:
Ok, now that all properties have been set, we can make the connection to the defined server. This can be done by using the Connect() method:
This should start the ICA client on your machine and connect to the server. Note that after you enter the command, it could take a few seconds before the ICA connection pops up. If no ICA connection is shown, verify that the OutputMode is set to OutputModeNormal and that the Launch property is set to true.
In a default XenApp installation, the server desktop is not enabled by default, so you could receive the following error:
This can easily be solved by setting a Citrix User Policy. Define a policy in your AppCenter and set a user policy: ICA > Desktop Launches > Set to Allowed.