A simple script to Logoff Users after n minutes of idle time. The time is hard code in the script.
Description
Presentation Server Administrator has the possibility to kick users after n minutes of idle time. This should be very useful for operational farm management where it should be necessary to logoff users for server maintenance.The following example calculates the delta between the current time and the last session input time. If the delta is equal or greater then the defined idle the Username, Clientname and Session Idletime will be print out and the session will be logged off.
Code Snippet
<package>
<job id="ks">
<comment>
</comment>
<reference object="MetaFrameCOM.MetaFrameFarm"/>
<script language="VBScript">
Dim objFarm, objSession, SessionList, t1, t2, minutes
Dim Year, Month, Day, Hour, Minute
'
' If an argument is given on the command line, it is the
' idle time in minutes. All sessions that have been idling
' longer than that time will be listed. The default is
' 5 minutes.
'
If WScript.Arguments.Count > 0 Then
minutes = CInt(WScript.Arguments(0))
Else
minutes = 5 'Enter here the idle time in minutes
End If
Set objFarm = CreateObject("MetaFrameCOM.MetaFrameFarm")
'
' Initialize the farm object.
'
objFarm.Initialize(MetaFrameWinFarmObject)
Set SessionList = objFarm.Sessions
WScript.Echo SessionList.Count & " sessions found"
For Each objSession In SessionList
Set t1 = objSession.LastInputTime(TRUE)
Set t2 = objSession.CurrentTime(TRUE)
Year = t2.Year - t1.Year
Month = t2.Month - t1.Month
Day = t2.Day - t1.Day
Hour = t2.Hour - t1.Hour
Minute = t2.Minute - t1.Minute
If Year >= 0 And Month >= 0 And Day >= 0 And Hour >= 0 Then
If Minute >= minutes Then
WScript.Echo "User Name: " & objSession.UserName
WScript.Echo "Client Name: " & objSession.ClientName
WScript.Echo "Minutes Idle: " & Minute
objSession.Logoff FALSE
End If
End If
Next
</script>
</job>
</package>
rate-21791550-42691
| User Rating? |
|
|
Disclaimer
These software applications are provided to you as is with no representations, warranties or conditions of any kind. You may use 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 software application 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 software application 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 software application. In no event should the code be used to support of 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 SOFTWARE APPLICATION, INCLUDING WITHOUT LIMITATION DIRECT, SPECIAL, INCIDENTAL, PUNITIVE, CONSEQUENTIAL OR OTHER DAMAGES, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. You agree to indemnify and defend Citrix against any and all claims arising from your use, modification or distribution of the code.
Hello,
I try to use your script without the web tags. I need a script logging out automatically an idle user.
So I adapted it. But I get an error msg for the line that contains MetaFrameCOM.MetaFrameFarm
I don't use cytrix, only wsh. What is this MetaFrame? Do I have to install something on the PC for your script to work?
Thank you for a small feed-back.
Greetings,
edubidu