How To Attach A Citrix Load Evaluator?
Friday, 11. April 2008 15:50
This article provides the script AttachLoadEvaluatorToServer.vbs that attaches a Load Evaluator to a Citrix terminal server. The script is proven in CPS 4.0 and 4.5 environments, and thanks to the hint of one of my fellows at Login Consultants it supports now the built-in Load Evaluators "Default" and "Advanced".
Given that you have a Load Evaluator to put a terminal server in offline mode – that is a Load Evaluator with an according Scheduling rule to disable ICA logons – this script is useful for automated installation or maintenance tasks.
Since AttachLoadEvaluatorToServer.vbs automates a Citrix server configuration it’s no surprise that it requires MFCOM. Therefore you should it execute on a Citrix terminal server. You need to specify the computer name of a terminal server in the farm and the exact name of the Load Evaluator as arguments. Listed below some examples to clarify the usage of the script…
This one attaches the Load Evaluator "DisableIca" to the Citrix server "ctx01":
cscript.exe AttachLoadEvaluatorToServer ctx01 DisableIca
To attach the Load Evaluator "Advanced" to the Citrix server that executes AttachLoadEvaluatorToServer.vbs type:
cscript.exe AttachLoadEvaluatorToServer %COMPUTERNAME% Advanced
Below you find the listing of the script:
'
' Script name: AttachLoadEvaluatorToServer.vbs
'
' Purpose: Attaches a load evaluator to a Citrix terminal server.
'
' Syntax: AttachLoadEvaluatorToServer servername lename
'
' servername The Citrix terminal server's computer name.
' lename The load evaluator's name (case sensitive)
'
' Author: Frank-Peter Schultze
'
' Last Update: 2008-04-11
'
Option Explicit
Const CTX_LE_DEFAULT = "MFDefaultLE"
Const CTX_LE_ADVANCED = "LMSDefaultLE"
Dim strCitrixServer : strCitrixServer = ""
Dim strLEName : strLEName = ""
Call GetArgs(strCitrixServer, strLEName)
Call AttachLEToServer(strCitrixServer, strLEName)
Sub AttachLEToServer(strCitrixServer, strLEName)
Dim objFarm
On Error Resume Next
Set objFarm = WScript.CreateObject("MetaFrameCOM.MetaFrameLoadEvaluator")
On Error GoTo 0
If IsObject(objFarm) Then
objFarm.LEName = strLEName
objFarm.LoadData(True)
objFarm.AttachToServerByName False, strCitrixServer
objFarm.SaveData()
Set objFarm = Nothing
Else
WScript.Echo "Can not create MFCOM object."
End If
End Sub
Sub GetArgs(ByRef strServer, ByRef strLEName)
Dim objArgs, strTmp
Set objArgs = WScript.Arguments
If (objArgs.Count = 2) Then
strServer = UCase(objArgs.Item(0))
strTmp = objArgs.Item(1)
Select Case LCase(strTmp)
Case "default"
strLEName = CTX_LE_DEFAULT
Case "advanced"
strLEName = CTX_LE_ADVANCED
Case Else
strLEName = strTmp
End Select
Else
Call Usage(True)
Exit Sub
End If
End Sub
Sub Usage(blnQuit)
WScript.Echo "Attaches a load evaluator to a Citrix farm server."
WScript.Echo
WScript.Echo WScript.ScriptName & " servername lename"
WScript.Echo
WScript.Echo " servername The Citrix terminal server's computer name."
WScript.Echo " lename The load evaluator's name (case sensitive)."
If blnQuit Then WScript.Quit
End Sub
Category:Scripting, VBScript | Comment (0) | Author: Frank-Peter
