Jason CitrixADmin wrote:
So if I use the following: @echo off /for /f %%i in (m:\testselfclose\labfarmlist.txt) do (query user %USERNAME% /server:%%i 2>NUL | find /i "%USERNAME%" > %TEMP%\%%i.txt/ / FOR /F "tokens=3" %%j in (%TEMP%\%%i.txt) do @logoff %%j /server:%%i)/ /for /f %%i in (m:\testselfclose\labfarmlist.txt) do (query user %USERNAME% /server:%%i 2>NUL | find /i "%USERNAME%" > %TEMP%\%%i.txt/ / FOR /F "tokens=2" %%j in (%TEMP%\%%i.txt) do @logoff %%j /server:%%i)/ / /
Hej Jason, it is not necessary to do the loop with tokens=2 AND tokens=3 As i have written: logoff requires either a session name or a session id.With tokens=3 you deliver a session id for active sessions and a session state for disconnected sessions. The latter is obviously not valid for any logoff operation, therefore the original version doesn't do anything with disconnected sessions.
With tokens=2 you deliver a session name for active sessions and a session id for disconnected sessions. Both are valid for logoff and you / the user get all it sessions from the servers logged off.
One hint: If possible, publish that script on a server the users do not use for regular operations. Reason: citrix likes to add new requests to old sessions if possible. Having a small server just for that stuff - your users won't get caught within any dead session.
hth, Marcus
It will release hung (Active) and disconnected session On Fri, Jun 6, 2014 at 10:09 AM, marcus <marcus@xxxxxxxxxxxxxx <mailto:marcus@xxxxxxxxxxxxxx>> wrote: Jason CitrixADmin wrote: I found the following script that is supposed to handle disconnected sessions, but I think it kills ALL disconnected sessions, not just those belonging to a user. Since I am not very good with scripts perhaps someone can verify, and verify that it works across morethan one server. / Logoff Disconnected Sessions ' If you want to logoff active sessions as well, change the query to include ' cActive On Error Resume Next Const cActive = 0 Const cDisconnected = 4 Const strComputer = "." Set objWMICitrix = GetObject("winmgmts:{__impersonationLevel=__impersonate}!\\" & strComputer & "\root\citrix") Set colItems = objWMICitrix.ExecQuery ("Select * from Metaframe_Session Where sessionstate = " & cDisconnected) For Each objItem in colItems if (objItem.SessionID > 0) and objItem.SessionID then objItem.Logoff end if Next / /Set objWMICitrix = Nothing/ Hej, i've found the solution for a users leftover (reason may vary) disconnected sessions: in the line where the logoff is done: change tokens=3 to tokens=2 logoff awaits either a session id or a session name. With tokens=2 disconnected sessions have the session id, active sessions have the session name. one more: i've stumbled upon an error when using "query user" and whitespace in the username. Switching to quser has fixed that for at least Srv 2003 R2. Weird but working cheers, Marcus Hej, first: many thanks, i've seen the script, tested and deployed it. As icon the red Powerbutton from Shell32.dll, a descriptive name - no room left for questions like "What's that for". One Question / an observation i made: what about disconnected sessions? As far as i've seen they aren't logged off. cheers, Marcus ******************************__****************** For Archives, RSS, to Unsubscribe, Subscribe or set Digest or Vacation mode use the below link: //www.freelists.org/list/__thin <//www.freelists.org/list/thin> ******************************__******************
************************************************For Archives, RSS, to Unsubscribe, Subscribe or set Digest or Vacation mode use the below link:
//www.freelists.org/list/thin ************************************************