Skip to content
View in the app

A better way to browse. Learn more.

MSFN

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.

Citrix Script

Featured Replies

I'm building a script to export all idle sessions in Citrix to Excel; so I have an overview

of the load on all servers from the Citrix Farm.

This is the script

Option Explicit

Dim objFarm, objSession, SessionList, tlst, tdis, tcur, t1, t2, minutes, i, fc
Dim SessionState
SessionState = Array("Unknown", _
"Active", _
"Connected", _
"Connecting", _
"Shadowing", _
"Disconnected", _
"Idle", _
"Listening", _
"Resetting", _
"Down", _
"Init")
Dim objFSO, objTextFile
Dim arrSessionsA, arrSessionsB, arrSessionInfoA, arrSessionInfoB
Dim strText, strSession, strSessionState, strCurDT, strCurDTcln, strDataOutFile2
Dim iA, iB
Dim duplicate
Const ForReading = 1
Const ForWriting = 2
Const ForAppending = 8
Const DataOutFile1 = "Idle_Sessions.csv"
Const DataInFile = "Idle_Sessions.csv"

strCurDT = now
i = 1
fc = 0
do until fc = 4
if Mid(strCurDT, i, 1) = "/" Then
fc = fc + 1
strCurDTcln = strCurDTcln & "-"
else
if Mid(strCurDT, i, 1) = ":" Then
fc = fc + 1
strCurDTcln = strCurDTcln & "-"
else
if Mid(strCurDT, i, 1) = " " Then
strCurDTcln = strCurDTcln & "_"
else
strCurDTcln = strCurDTcln & Mid(strCurDT, i, 1)
end if
end if
end if
i = i + 1
loop
strCurDTcln = strCurDTcln & Mid(strCurDT, i, 1)
strCurDTcln = strCurDTcln & Mid(strCurDT, i + 1, 1)
strDataOutFile2 = strCurDTcln & "_Idle_Sessions_filtered.csv"

'open file in Append mode
Set objFSO = CreateObject("scripting.filesystemobject")
Set objTextFile = objFSO.OpenTextFile(strDataOutFile2, ForAppending, True)
Set objFarm = CreateObject("MetaFrameCOM.MetaFrameFarm")
' Initialize the farm object.
objFarm.Initialize(MetaFrameWinFarmObject)

Set SessionList = objFarm.Sessions
For Each objSession In SessionList
Set tlst = objSession.LastInputTime(TRUE)
Set tdis = objSession.DisconnectTime(TRUE)
Set tcur = objSession.CurrentTime(TRUE)

strSessionState = SessionState(objSession.SessionState)
t2 = tcur.minute + tcur.hour*60



if strSessionState = "Active" Then
t1 = tlst.minute + tlst.hour*60
minutes = t2 - t1
If Minutes > 120 Then
Minutes = 0
End if
End if


if strSessionState = "Disconnected" Then
t1 = tdis.minute + tdis.hour*60
minutes = t2 - t1 + 120
If Minutes > 240 Then
Minutes = 240
End if

If Minutes < 0 Then
Minutes = 0
End if
End if

'write session info to file

objTextFile.writeline (objSession.ServerName & "," & objSession.UserName & "," & _
objSession.SessionName & "," & CStr(objSession.SessionID) & "," & _
objSession.ClientName & "," & strSessionState & "," & Minutes)
Next

'close file
objTextFile.close

'open file for Reading into sort arrays
Set objTextFile = objFSO.OpenTextFile(strDataOutFile2, ForReading, True)
strText = objTextFile.ReadAll
objTextFile.Close

Set objTextFile = objFSO.OpenTextFile (strDataOutFile2, ForWriting, True)
arrSessionsA = Split(strText, vbCrLf)
arrSessionsB = Split(strText, vbCrLf)
iA = 0
duplicate = 0
do until arrSessionsA(iA) = ""
arrSessionInfoA = Split(arrSessionsA(iA), ",")
iB = iA + 1
do until arrSessionsA(iB) = ""
arrSessionInfoB = Split(arrSessionsB(iB), ",")
'compare username AND server AND sessionid AND workstation name
if arrSessionInfoA(1) = arrSessionInfoB(1) AND _
arrSessionInfoA(0) = arrSessionInfoB(0) AND _
arrSessionInfoA(3) = arrSessionInfoB(3) AND _
arrSessionInfoA(4) = arrSessionInfoB(4) then
duplicate = 1
exit do
end if
iB = iB +1
loop
if duplicate = 1 then
duplicate = 0
else
objTextFile.WriteLine (arrSessionsA(iA))
end if
iA = iA + 1
loop
objTextFile.Close


I Receive an error on line 54

"Set objFarm = CreateObject("MetaFrameCOM.MetaFrameFarm")"

Can someone help me?

Thx

Edited by verlegenmanneke


Create an account or sign in to comment

Recently Browsing 0

  • No registered users viewing this page.

Account

Navigation

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.