Query MetaFrame XP Farm for Client Name, UserName, Client IP Address and Application Name
Use VB Script to query session information from your MetaFrame XP Farm
Did you know that you can build your own VB Scripts to query useful information from your MetaFrame XP Farm.
Here is some of the things you can query for:
1. Active Session Client IP Addresses
2. Active Session ICA Client Names
3. Active Session User Names
4. Active Session Applications
5. Farm Information
4. Application Users
4. And much more
Useful Scripts are Included in the Citrix SDK
Included in the Citrix SDK are sample programs, source code and VB Scripts.
Choose one server in your Farm to install the Citrix SDK onto and you will soon be querying with the sample programs and scripts.
Below is a sample script that will enumerate all active sessions for:
UserName,ClientName,ClientAddress,ApplicationName.
You can pipe the output to a text file, something like this:
CScript "Path"\SessionInfo.wsf > "Path"\ActiveSessions.txt
Then you can import the text file into Microsoft Excel or any spreadsheet program and sort it any way you desire.
You must have the Citrix SDK 2.3 installed for this script to work.
SessionInfo.wsf
Summary: This script was very useful for us when migrating from an old Farm to a New Farm and needed a current list of client information with Client IP Addresses. Which allowed us to sort the list by Application name, UserName or Client IP to identify who and where the people were that needed to migrate to the new Farm. This script is also good for documenting ICA Clients that have no name asigned to them.
The
scripts are also useful in documenting your MetaFrame XP environment in
an automated manner.
Sessions.wsf Script (New Improved Version)
<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
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.
'
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 "------------------------------------------------" On
Error Resume
Next
For Each aSession In theFarm.Sessions
WScript.Echo aSession.UserName & ", " & aSession.ClientName &
", " & aSession.ClientAddress & ", " & aSession.AppName
Next
</script>
</job> </package>
|