Get-brokersession | Where-Object {$_.sessionstate -eq "Disconnected" -and $_.sessionstatechangetime -lt (Get-date).AddHours(-4)} | stop-brokersession
Use this command to stop sessions that have been disconnected for 4 hours. This could be useful when the Timings you want are not accepted by the Sessions GPO setting.
Stop disconnected sessions that have been disconnected for 4 hours. XenApp 7.*
May 12, 2016