How to log off the sessions which are disconnected more than 1 hour via powershell

How to log off the sessions which are disconnected more than 1 hour via powershell

book

Article ID: CTX477036

calendar_today

Updated On:

Description

Sometimes, user needs to log off the sessions which are in disconnected state for more than 1 hour through powershell.

Resolution

Provide the powershell script as below:
Customer can query the result and verify first.
After confirmation, the customer can terminate these disconnected sessions using the last command.
#######################################################
asnp Citrix*

#Set the Disconnected session timer interval, The unit is minutes
$timerInterval=60

#Query the Disconnected Session that meets the conditions
Get-BrokerSession|where {$_.SessionState -eq "Disconnected" -and $_.SessionStateChangeTime.AddMinutes($timerInterval) -lt (get-date)}

#Terminate the Disconnected Session that meets the conditions
#Get-BrokerSession|where {$_.SessionState -eq "Disconnected" -and $_.SessionStateChangeTime.AddMinutes($timerInterval) -lt (get-date)}|Stop-BrokerSession
#######################################################


Problem Cause

Question on how to log off the sessions which are in disconnected state for more than 1 hour.