Can't Logoff Ghost Sessions “-” from Citrix Studio

Can't Logoff Ghost Sessions “-” from Citrix Studio

book

Article ID: CTX556635

calendar_today

Updated On:

Description

Can't logoff the session in Studio, which is not even shown in VDA task manager.
Customer tried to hide the session with the below Powershell command, but this ghost session record still exists on Studio. 

"Get-BrokerSession -username Domain\username | Set-BrokerSession -hidden $true"

Need to figure out alternative ways to remove these ghost sessions.

Note: username in the article is lab username not customer's information

Environment

The above mentioned sample code is provided to you as is with no representations, warranties or conditions of any kind. You may use, modify and distribute it at your own risk. CITRIX DISCLAIMS ALL WARRANTIES WHATSOEVER, EXPRESS, IMPLIED, WRITTEN, ORAL OR STATUTORY, INCLUDING WITHOUT LIMITATION WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, TITLE AND NONINFRINGEMENT. Without limiting the generality of the foregoing, you acknowledge and agree that (a) the sample code may exhibit errors, design flaws or other problems, possibly resulting in loss of data or damage to property; (b) it may not be possible to make the sample code fully functional; and (c) Citrix may, without notice or liability to you, cease to make available the current version and/or any future versions of the sample code. In no event should the code be used to support ultra-hazardous activities, including but not limited to life support or blasting activities. NEITHER CITRIX NOR ITS AFFILIATES OR AGENTS WILL BE LIABLE, UNDER BREACH OF CONTRACT OR ANY OTHER THEORY OF LIABILITY, FOR ANY DAMAGES WHATSOEVER ARISING FROM USE OF THE SAMPLE CODE, INCLUDING WITHOUT LIMITATION DIRECT, SPECIAL, INCIDENTAL, PUNITIVE, CONSEQUENTIAL OR OTHER DAMAGES, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. Although the copyright in the code belongs to Citrix, any distribution of the sample code should include only your own standard copyright attribution, and not that of Citrix. You agree to indemnify and defend Citrix against any and all claims arising from your use, modification or distribution of the sample code.

Resolution

  1. Click Studio->Configuration to check the current SQL Server
  2. Take snapshots for all the DDCs and SQL Servers
  3. Backup the Site, Monitoring and Logging database
  4. Go to DDC and Open PowerShell to run the command to check the ghost session's session key
Asnp Citrix*  Get-BrokerSession | Select username, Machinename, Sessionkey
  1. Go to Site Database to check the following tables.  Then delete records associated with the session key identified in step 4

[CitrixSiteDBName].[chb_State].[Sessions] 

[CitrixSiteDBName].[chb_State].[Licenses]

[CitrixSiteDBName].[chb_State].[BrokeredSessions] 

  1. You need to create a new query in the menu of SQL Server Management Studio and input SQL Command like this for completing the deletion:

Delete From [[CitrixSiteDBName].Chb_State.Sessions Where Sessionkey=’xxxxxxxxxxxxxx’ 

  1. Select SQL CMD Mode and Click Execute


For example:
Find sessionkey=03A07F10-E1AF-4BB5-AF47-2E08840527B5
 
DELETE from [CitrixSiteDBName].[chb_State].[Licenses] WHERE sessionkey= 03A07F10-E1AF-4BB5-AF47-2E08840527B5   if exists

DELETE from [CitrixSiteDBName].[chb_State].[Sessions]  WHERE sessionkey= 03A07F10-E1AF-4BB5-AF47-2E08840527B5    if exists

DELETE from [CitrixSiteDBName].[chb_State].[BrokeredSessions]  WHERE sessionkey= 03A07F10-E1AF-4BB5-AF47-2E08840527B5  , if exists


Problem Cause

Session records can't be cleared away from the site database which leads to failures to login to VDA via ICA.