[Last Call] Learn how to a build a cloud-first strategyRegister Now


Citrix PS4.5 - Script Session Reset w/ Specific Criteria

Posted on 2011-04-27
Medium Priority
Last Modified: 2012-06-21
Our environment is currently 5 x Windows 2003 Server Enterprise 32bit servers running Presentation Server 4.5 in a farm.

We have an application that does not close properly when a session is reset, which locks the user in the database the application uses.  The application itself does not have a built-in idle timer, so I can't query it to execute the script I need.  This also throws out the use of Group Policy, as the auto-reset functionality of Terminal Services won't work.  

I need a script (MFCOM / POWERSHELL / VB / Anything) that helps me accomplish the following:

Query farm (or just server) for a list of users by application, username, and idle time

If idle time >= 15 minutes and application =X and username = X, do nothing

If idle time >= 15 minutes and application = X and username = Y, pass the username to a variable that can then be added to the end of a website script we use:  http://www.website.com/script.asp?kick=username

Reset the session tied to this user

I would like to run this script as a scheduled job via Windows Task Scheduler every 5 minutes.  I have a list of users I want this script to work on and a list of users I want to be excluded from it.  If it is easier to create this script per Citrix box, I am open to doing it that way and having each server run their own scheduled task to accomplish the above.

I do NOT have the Powershell or MFCOM SDK installed on these servers, so if you could point me to a resource on how to install/setup whatever coding infrastructure is needed for these scripts to run properly (including what command I need to pass to Windows Task Scheduler in order for the script to execute), I would really appreciate it.

Please let me know if there is any additional information required and I will do my best to get you the detail you need.

Thanks in advance!
Question by:Mathius123
  • 2

Expert Comment

ID: 35480643
Check out the query user command instead, you can get most of the parameters you are looking for (active/disconnect, idle, userid and session id)  When you find your idle user, that is a valid user on the server you are running the task on, you could validate with query process to validate the specific process, and continue processing from there.  I use a nice tool called autoit for task like these.  You could even wrap the start-up of the application into your script, have a loop that looks for the idle, only publish the wrapped application to the users you are worried about, it starts with the identified user/application, finds idle during loop, breaks loop and processes the rest of your shutdown process.

Accepted Solution

Mathius123 earned 0 total points
ID: 35491144
I figured it out using MFCOM and VBScript.  If anyone wants a copy of the code I used to accomplish this, please contact me and let me know.

Author Closing Comment

ID: 36458799
I was able to figure it out on my own.

Expert Comment

ID: 37600815
Mathias, I would like a copy of the script that you put together for this.  I'm having issues with published Lync 2010 and the service continuing to run for idle users.

Featured Post

Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

A recent project that involved parsing Tableau Desktop and Server log files to extract reusable user queries for use in other systems. I chose to use PowerShell to gather the data, and SharePoint to present it...
In this post, I will showcase the steps for how to create groups in Office 365. Office 365 groups allow for ease of flexibility and collaboration between staff members.
Loops Section Overview
Screencast - Getting to Know the Pipeline

834 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question