Picture the following setting: A rainy Sunday afternoon. You need to prepare some presentation slides for a sales pitch the following day. You are working from home and are logged in on the company’s virtual desktop (running Citrix XenDesktop). Everything is fine and you are almost done. Suddenly the screen freezes, everything is locked and you are unable to continue your preparation. You disconnect your session and try a reconnect, which is not successful.
Sadly the support desk is only available during business hours.
What should you do?
C. Start all over again on your local machine
D. All of the above
Now this is a pretty specific setting, but a customer sometimes had similar issues. Users are working in the weekend and need to contact an administrator just to logoff their session. How can you solve this with RES ONE Service Store?
I know what you are thinking: Why not solve the session lockups and the reconnects? And I agree, this should be the top priority. But a workaround for the user is always helpful. Especially when it doesn’t require action from an administrator.
To accomplish this I created a RES ONE Service Store service that does just that. A user can connect to the RES ONE Service Store website or use the app from their personal device and request the service. The service will call a RES ONE Automation Run Book that will search the XenDesktop sites for sessions of that specific user. If it finds any it will logoff those sessions.
After that it will query the XenDesktop site for a maximum of one minute until the session is logged off. When the session is gone or the timeout is reached the Run Book will relay its results back to the service and inform the user.
Since sharing services is the main topic of this website I’m also sharing the building blocks for this service. The download link is on the bottom of this post.
But first I will give a quick walkthrough of the service and what parameters you need to specify to get it working in your environment.
First the RES ONE Service Store service. Initially this one was quite simple: Just an ‘Invoke Run Book’ workflow action and that’s it. But then you start tweaking and improving/worsening the service and it gets a bit more elaborate.
The service that I have put up for download contains the following actions:
– Start Delivery
– Invoke Run Book
Described below. Outputs an exit code back to the TaskResult service attribute and also a task log to the TaskLog service attribute
Exit codes are as follows:
5: No session(s) found
10: Session(s) logged off
20: Log off of session(s) failed
– Compare attribute
It will check if the TaskResult attribute is equal to exit code 5. If true it will set the ServiceResult attribute to the corresponding Result5 attribute which holds the message for the user. After that it will jump to the final ‘Inform user about results’ action. If false it will jump to the next ‘Compare attribute’ action.
– Compare attribute
It will check if the TaskResult attribute is equal to exit code 10. If true it will set the ServiceResult attribute to the corresponding Result10 attribute which holds the message for the user. After that it will jump to the final ‘Inform user about results’ action. If false it will jump to the next ‘Compare attribute’ action.
– Compare attribute
It will check if the TaskResult attribute is equal to exit code 20. If true it will set the ServiceResult attribute to the corresponding Result20 attribute which holds the message for the user. After that it will jump to the final ‘Inform user about results’ action. If false it will set the ServiceResult to the corresponding ResultNo attribute.
– Send message
The last action will send a message to the Service Store message box. The message will contain the value of the ServiceResult and the TaskLog attributes. So basically it will tell you if the transaction succeeded and show a short log file of the logoff command.
Next there is the RES ONE Automation Run Book. It contains a module with a single PowerShell tasks which contains the script. Now I’m not the best PowerShell scripter in the world so I know some things in it could be done in a better and/or more efficient way. But still, it does the job. Basically it gets the Windows user account from RES ONE Service Store and connects to the XenDesktop site through the PowerShell SDK. There it will query the sessions of the user and will logoff the sessions if its finds any.
You can configure the Run Book to run on one of the Delivery Controllers or on any other server. Requirements for the latter option are that Citrix Studio should be installed and it should be able to communicate with one of the XDC’s. If you go for this option, then you would need to specify which XDC it connects to. More on this in a bit.
Finally the building blocks (download link below). It is divided in a building block for ROA and a building block for ROSS. Do the import for ROA first. When importing it will ask you to provide the values for three parameters:
DefinedXDC – Give the name/FQDN/IP of the XDC you would like to use for the logoff (leave empty when running the Run Book on the XDC itself)
SecurityContext-XenDesktop – Supply credentials with the permission to log off sessions (Help Desk Administrator or the ‘Perform session management on machines via Delivery Group membership‘-permission)
RunBookWho – Supply the name of the agent on which the Run Book should be scheduled (NetBIOS name of the machine)
After that import the building block for ROSS. When importing it will ask to map the used ‘Windows user account’ people identifier to a similar identifier in your setup (but I’m guessing most of you are using the same default identifiers). Of course you can use whatever identifier/attribute you like, as long as it is in the DOMAIN\USER format.
When the import is done you need to make sure the Run Book Parameters and Results are setup correctly. Open the Invoke Run Book workflow action and make sure it is linked to the appropriate Run Book (Logoff active XenDesktop session). Also make sure the Run Book Parameters are linked in the following way:
Run Book Parameters:
DefinedUser -> #Service[DefinedUser]
TaskResult -> #Service[TaskResult]
TaskLog -> #Service[TaskLog]
Run Book Results:
TaskLog -> TaskLog
TaskResult -> TaskResult
Seems obvious enough, right? The rest of the Run Book Results should be ‘Not Set’.
And that’s it for the Building Block import. Make sure the triggers for Delivery (Request) and Return (auto deprovisioning) are set in both workflows. Set the option ‘Show in Service Store’ to enabled and finally, enable transactions.
Just be sure to test the service before you offer it to your users.
If you have any suggestions, improvements or complaints, feel free to contact me about it.
534 total views, 2 views today