Find-XASessions


posted by Axel Kara
11-26-2009

Downloads: 283
File size: 890 B
Views: 1,365

Embed
Find-XASessions
  1. function Find-XASessions ($AccountName) { 
  2. #   
  3. #      .SYNOPSIS   
  4. #          Finds all sessions of a user 
  5. #        .DESCRIPTION 
  6. #          Finds all sessions of a user within the current Citrix farm,  
  7. #        where the user name contains a part of the string you passed  
  8. #         to the -AccountName parameter 
  9. # 
  10. #         Requires Citrix.XenApp.Commands PSSnapIn 
  11. #      .NOTES   
  12. #         File Name: Find-XASessions.ps1   
  13. #         Author:    Axel Kara, axel.kara@gmx.de   
  14. #      .EXAMPLE   
  15. #          Find-XASessions -AccountName "m" 
  16. #   
  17.      
  18.     #Here you can change the properties that should be returned 
  19.     $Properties = 'AccountName','ServerName','SessionId','SessionName','State','ClientName' 
  20.  
  21.     #Query and filter all sessions 
  22.     Get-XASession | Select-Object -Property $Properties | Where-Object {$_.AccountName.ToUpper().Contains($AccountName.ToUpper())} | Format-Table 
  23.  

Returns a collection of session objects where the AccountName property starts with the passed -AccountName parameter

EXAMPLE:

Find-XASessions -AccountName 'mydomain\m'

Will return all sessions of 'mydomain\Max' and 'mydomain\Michael' (and all other users who's account name starts with'mydomain\m').

NOTE:

This function requires the Citrix.XenApp.Commands PSSnapIn.

 

see also Find-CTXSessions

Comments

Axel Kara wrote re: Find-XASessions
on 11-26-2009 1:33 AM

If using this function within a script, you can make sure that the Citrix.XenApp.Commands PSSnapIn is active by adding this command...

Add-PSSnapin -name Citrix.XenApp.Commands -ErrorAction SilentlyContinue

Concentrated Tech NSoftware Dell Compellent Sponsored by Idera and Concentrated Tech and NSoftware and Dell Compellent
Copyright 2011 PowerShell.com. All rights reserved.