Jump to content
Welcome to our new Citrix community!
  • 0

Powershell equivalent for Get-XASessionProcess & Stop-XASessionProcess in xenapp 7.x


Lokesh S

Question

I am looking for the powershell cmdlets that help me to kill only the specific application of a particular user from the specified server.

We have the command Get-XASessionProcess & Stop-XASessionProcess in XA 6. Is there any cmdlets that help to achieve the same in xenapp 7.x.

 

 

Link to comment

8 answers to this question

Recommended Posts

  • 0

Get-BrokerApplicationInstance -UserName "DOMAIN\Username"

 

$app = Get-BrokerApplicationInstance -SessionUid "SessionUIDNumberOfApplicationYouWantToEnd"

 

Stop-BrokerSession $app.SessionUid

 

Now the above is based on a user that has for example two applications open from two different Delivery Groups. If users have multiple applications open from the same Delivery Group I don't know if there is a way to specifically end one of the applications sessions. Use Director for that.

Link to comment
  • 0

I am developing the self help tool for the user, the tool will be listing all the user session and the applications launched by them. User will be able to select the specific application and kill it.

For eg,

user has 2 sessions.

session1(server1) --> app1, app2, app3.

session2(server2) --> app4, app5.

 

I wish to clse app3 alone launched by user. The Stop-brokersession will close the session completely rather than app3 alone.

 

The same can be achieved from the Get-XASessionprocess & stop-XAsessionprocess in older Xenapp.

Is there any powershell command that help me to do the task I required in XA 7.x.

Link to comment
  • 0

It is interesting this ability is given via the Xendesktop Director. You are able to terminate individual applications and view processes, however the ability to see the Process ID for whatever reason is not visible, this makes it very hard to terminate a application with the same process name. This makes me believe that they could easily implement this ability to duplicate the functionality you are asking for.  

Link to comment
  • 0

The feature slokesh89 mentions to kill a specific application via powershell is something that my business requires as well.  It was something that was required in 6.5 and it is required now.   Having a script that allows an end user to quickly and easily self administrate a hung session helps our on call rotation enjoy more time with their family or get a few more hours of sleep at night.  If anyone has any idea on how to accomplish this it would be extremely welcome.

 

 

Edited by cmwoodman
removed rant
Link to comment
  • 0

OK, thought i would sheepishly ask for forgiveness for my past rant and post this here as a follow up, and hopefully it will help someone else with this issue:

 

did some more digging and this is a feature that the 7.x farms have by default (sessionsharing) here are a couple of articles that explain it and also how to turn it off so you can have users launch apps in seperate sessions.

 

https://www.citrix.com/blogs/2017/02/27/xenapp-and-xendesktop-7-13-launching-an-application-in-multiple-sessions/

 

https://support.citrix.com/article/CTX232362 

 

have fun

Link to comment
  • 0

I have the same issue - we have an application with a limited number of concurrent licenses, so instead of running out, we want to terminate apps that have been idle for a certain amount of time.  We do have session sharing turned on so we don't want to log off the session, just kill the process.  I found it was possible with WMI.

 

To do this you need the executable name or the full path to the executable, ie. "C:\Windows\System32\Notepad.exe"  In our environment we use the full path to make sure we are finding the process we want.

 

Start by running "$Sessions = Get-BrokerSession -ApplicationsInUse $AppName", where $AppName is the application name and folder as it is in the XenApp studio.  If you had a folder "Apps" and an application "Microsoft Word", then $AppName would be "App\Microsoft Word".

 

This will give you a list of sessions.  If you want to limit these in some way, you can. As I mentioned, we use IdleDuration to figure out which ones we want.  From each session you can get the username in "Domain\Username" format, and the server name where the session is running, which are properties of a BrokerSession.

 

Now get a list of processes on the remote server using WMI:

 

[array]$AppProcesses = Get-WmiObject -Class Win32_Process -ComputerName $Server -Filter "executablePath='$ProcessPath'"

 

You need to force it to be an array because if there's only one process with that path on the server it will return an object instead of an array, and with [array] specified we don't have to handle that special case.

 

So now you have a list of processes running a particular application on a particular server.  Now you need to check and see which one(s) belong to the user you're after.  You can find the user name and domain by using the GetOwner() function of the process object, for example $AppProcess.GetOwner().User and $AppProcess.GetOwner().Domain..

 

Compare this to the domain\username you are looking for, and if it's a match, run $AppProcess.Terminate().

 

 

 

Link to comment

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...