Script to List, Query and Assign Load Evaluator on Citrix Metaframe Server
Create a file call is LE.vbs and copy script below to that file.
Then go to command prompt switch directory to the one you saved script to and run the script:
If you only use server name as a prarameted you will get a list of all available load evaluators.
Also the on that is currently assigned to a server will be marked by "*" sign
Command:
LE.vbs MYCTXSRV01
Output:
List of available Load Evaluators:
* - current LE assigned to a server
LMSDefaultLE
MFDefaultLE
* VM Servers
Offline
If you use this with the Load evaluator name script will assign it to the server and then print the list of load evaluators again
If Load evaluator has space in the name use quotations.
Command:
LE.vbs MYCTXSRV01 "VM Servers"
'--/ BEGIN SCRIPT /--'
If (WScript.Arguments.Count <> 2) Then
Dim mfFarm
Dim mfLE
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 farm server's computer name."
WScript.Echo " If load evaluator's name has space quotation."
WScript.Echo ""
WScript.Echo ""
if (WScript.Arguments.Count = 1) then
ListLE GetCurrentLE(WScript.Arguments(0))
end if
WScript.Quit
End If
SetLE WScript.Arguments(0), WScript.Arguments(1)
ListLE GetCurrentLE(WScript.Arguments(0))
'-------- functions
Sub SetLE(strFarmServer, strLEName)
Set objFarm = CreateObject("MetaFrameCOM.MetaFrameLoadEvaluator")
objFarm.LEName = strLEName
objFarm.LoadData(True)
objFarm.AttachToServerByName False, strFarmServer
objFarm.SaveData()
Set objFarm = Nothing
End Sub
Sub ListLE(CurrLE)
WScript.Echo "List of available Load Evaluators:"
WScript.Echo "* - current LE assigned to a server"
WScript.Echo
chk = " "
Set mfFarm = CreateObject("MetaFrameCOM.MetaFrameFarm")
mfFarm.Initialize 1
For Each mfLE In mfFarm.LoadEvaluators
mfLE.LoadData 1
if CurrLE <> "" then
if mfLE.LEName = CurrLE then chk = "* " else chk =" "
end if
WScript.Echo " " & chk & mfLE.LEName
Next
Set mfFarm = Nothing
End Sub
Function GetCurrentLE(ServerName)
set objServer = CreateObject("MetaFrameCOM.MetaFrameServer")
objServer.Initialize 6, ServerName
Set objLE = objServer.AttachedLE
objLE.Loaddata(True)
GetCurrentLE = objLE.LEName
set objServer = Nothing
End Function
'---END SCRIPT--'
Then go to command prompt switch directory to the one you saved script to and run the script:
If you only use server name as a prarameted you will get a list of all available load evaluators.
Also the on that is currently assigned to a server will be marked by "*" sign
Command:
LE.vbs MYCTXSRV01
Output:
List of available Load Evaluators:
* - current LE assigned to a server
LMSDefaultLE
MFDefaultLE
* VM Servers
Offline
If you use this with the Load evaluator name script will assign it to the server and then print the list of load evaluators again
If Load evaluator has space in the name use quotations.
Command:
LE.vbs MYCTXSRV01 "VM Servers"
'--/ BEGIN SCRIPT /--'
If (WScript.Arguments.Count <> 2) Then
Dim mfFarm
Dim mfLE
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 farm server's computer name."
WScript.Echo " If load evaluator's name has space quotation."
WScript.Echo ""
WScript.Echo ""
if (WScript.Arguments.Count = 1) then
ListLE GetCurrentLE(WScript.Arguments(0))
end if
WScript.Quit
End If
SetLE WScript.Arguments(0), WScript.Arguments(1)
ListLE GetCurrentLE(WScript.Arguments(0))
'-------- functions
Sub SetLE(strFarmServer, strLEName)
Set objFarm = CreateObject("MetaFrameCOM.MetaFrameLoadEvaluator")
objFarm.LEName = strLEName
objFarm.LoadData(True)
objFarm.AttachToServerByName False, strFarmServer
objFarm.SaveData()
Set objFarm = Nothing
End Sub
Sub ListLE(CurrLE)
WScript.Echo "List of available Load Evaluators:"
WScript.Echo "* - current LE assigned to a server"
WScript.Echo
chk = " "
Set mfFarm = CreateObject("MetaFrameCOM.MetaFrameFarm")
mfFarm.Initialize 1
For Each mfLE In mfFarm.LoadEvaluators
mfLE.LoadData 1
if CurrLE <> "" then
if mfLE.LEName = CurrLE then chk = "* " else chk =" "
end if
WScript.Echo " " & chk & mfLE.LEName
Next
Set mfFarm = Nothing
End Sub
Function GetCurrentLE(ServerName)
set objServer = CreateObject("MetaFrameCOM.MetaFrameServer")
objServer.Initialize 6, ServerName
Set objLE = objServer.AttachedLE
objLE.Loaddata(True)
GetCurrentLE = objLE.LEName
set objServer = Nothing
End Function
'---END SCRIPT--'
Comments
Post a Comment