Tuesday, July 15, 2008

Assigning Citrix Load Evaluator from PowerShell

Well, still lot of stuff to learn about MFCOM behavior :(

I already run into this issue few times and I wanted to clarify that Citrix XenApp 4.5 have same issue.

There are two different ways how to assign Load Evaluator using MFCOM.

Server based

First makes more sense to me:

1.) Load server object

2.) Assign load evaluator to server

Problem with this approach is that sometimes (= quite often) something goes wrong in MFCOM. If you ask MFCOM about assigned load evaluator, you get correct answer:

PS C:\Temp> MFCOM:Assign-LoadEvaluator -Server ctxs-ctp -LoadEvaluator Default

In this case True means that load evaluator assigned is SAME as requested (-LoadEvaluator).

When I try to manually double-check, everything looks fine:

PS C:\Temp> $CtxServer = $CitrixFarm.GetServer([MF.Object]::WinSrvObject, "ctxs-ctp")
PS C:\Temp> $LE = $CtxServer.AttachedLE
PS C:\Temp> $LE.LoadData($True)
PS C:\Temp> $LE.LEName
PS C:\Temp>

If you however look in CMC, you see old load evaluator:


Hmmmmm, that is really strange. To make it even more confusing, lets select Load Evaluators in CMC:

image Now change view to report "By Evaluator" - here we go, our server have 2 Load Evaluators assigned :(


 Load Evaluator based

You can also use second method

1.) Get Load Evaluator

2.) Assign server to it

I don't like this method, it doesn't sound that good to me - I want to assign Load Evaluator to server, not other way around.

Problem is that this method works :(

$RequestedLE = New-Object -ComObject MetaFrameCOM.MetaFrameLoadEvaluator
$RequestedLE.LEName = $LoadEvaluator
$RequestedLE.AttachToServerByName($True, $Server)



Vishal said...

Hi Martin
This is a very cool script. Can you please post it on CDN Script exchange too? CDN script exchange is a wiki site where you can upload your samples and get more visibility.

Click here to learn how to upload samples on CDN


Vishal Ganeriwala

Martin Zugec said...

Hi Vishal,

I already found CDN, however right now I am creating my repository of citrix related scripts - not only scripts themselves, but also custom enumerations ([MF.Color], [MF.Object] etc) and I will post them all at once.