RSS

vbs scripting, getting session counts on citrix servers

01 Oct

from:
http://forums.citrix.com/thread.jspa?messageID=1388763

<package>
<job id="Sessions">

<comment>

File: Sessions.wsf
Description: List sessions in the farm.
Requirements: WSH 5.5 or higher.

Copyright (c) 2002 Citrix Systems, Inc.

</comment>
<runtime>
<description>
List sessions in the farm.
</description>
<example>
CScript //nologo Sessions.wsf
</example>

</runtime>
<reference object="MetaFrameCOM.MetaFrameFarm"/>
<script language="VBScript">

Dim theFarm, aSession, SessionState, TotalCount

SessionState = Array("Unknown", _
"Active", _
"Connected", _
"Connecting", _
"Shadowing", _
"Disconnected", _
"Idle", _
"Listening", _
"Resetting", _
"Down", _
"Init")


‘ Create MetaFrameFarm object

Set theFarm = CreateObject("MetaFrameCOM.MetaFrameFarm")
if Err.Number <> 0 Then
WScript.Echo "Can’t create MetaFrameFarm object"
WScript.Echo "(" & Err.Number & ") " & Err.Description
WScript.Echo ""
WScript.Quit Err.Number
End if


‘ Initialize the farm object.

Set xaFarm = CreateObject("MetaFrameCOM.MetaFrameFarm")
xaFarm.Initialize(1)

theFarm.Initialize(MetaFrameWinFarmObject)

if Err.Number <> 0 Then
WScript.Echo "Can’t Initialize MetaFrameFarm object"
WScript.Echo "(" & Err.Number & ") " & Err.Description
WScript.Echo ""
WScript.Quit Err.Number
End if


‘ Are you Citrix Administrator?

if theFarm.WinFarmObject.IsCitrixAdministrator = 0 then
WScript.Echo "You must be a Citrix admin to run this script"
WScript.Echo ""
WScript.Quit 0
End If


‘ Print out the farm name.

‘WScript.Echo "MetaFrame Farm Name: " & theFarm.FarmName
‘WScript.Echo ""


‘ Display all sessions in the farm.

‘WScript.Echo "All sessions in the farm (" & Now & ")"
‘WScript.Echo ""

for each xaApp in xaFarm.Applications
xaApp.LoadData(false)

if xaApp.AppName = "EMR" then
wscript.echo xaApp.Sessions.Count & "," & Now & ""
End If

Next
‘WScript.Echo i & "," & Now & ""
‘WScript.Echo "Press ENTER to exit…"
‘WScript.StdIn.Read(1)

</script>
</job&gt;
</package>

Advertisements
 
Leave a comment

Posted by on October 1, 2009 in Uncategorized

 

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

 
%d bloggers like this: