XenApp: Create “Offline” Load Evaluator
Sunday, 27. July 2008 23:00
Administrators of Citrix XenApp (formerly known as: Presentation Server) normally use a Load Evaluator with an empty Schedule Rule to take a server offline for maintenance or troubleshooting purposes. An empty Schedule Rule maximizes the server’s load, thus it won’t accept any new ICA sessions while all active sessions are not affected. Compared to CHANGE LOGON /DISABLE the "Offline Load Evaluator" allows disconnected user’s to reconnect to their sessions, and Administrators are still able to establish new RDP sessions.
The PowerShell script in this article uses MFCOM to create the Load Evaluator and can be used in automated Citrix Farm setups (like Login Consultants‘ Solution4 framework)
Creating a new Load Evaluator and attaching a Rule to it is straightforward:
# NAME
# Add-DisableICALogonLE.ps1
#
# SYNOPSIS
# Creates a Load Evaluator with an empty Schedule Rule.
#
# SYNTAX
# .\Add-DisableICALogonLE.ps1 -name Name [-description Description]
#
# DETAILED DESCRIPTION
# A Load Evaluator with an empty Schedule Rule will maximize a XenApp
# server's load. Thus, it won't accept new ICA sessions while active
# and disconnected sessions are not affected.
#
# AUTHOR
# Frank-Peter Schultze www.fpschultze.de
#
# DATE
# 27-Jul-2008
Param(
$name = $(throw "Load Evaluator name must be specified"),
$description = "Takes server offline for maintenance purposes"
)
$MetaFrameWinFarmObject = 1
$LMRuleSchedule = 5
$myfarm = New-Object -ComObject "MetaFrameCOM.MetaFrameFarm"
$myfarm.Initialize($MetaFrameWinFarmObject)
$myfarm.LoadEvaluators | %{if ($_.LEName -eq $name) {
Write-Warning "The load evaluator `"$name`" already exists."; break
}
}
Write-Verbose "Creating Load Evaluator `"$name`" . . ."
$newrule = New-Object -ComObject "MetaFrameCOM.MetaFrameLMRule"
$newrule.RuleType = $LMRuleSchedule
$allrules = New-Object -ComObject "MetaFrameCOM.MetaFrameLMRules"
$allrules.AddRule($newrule)
$newle = New-Object -ComObject "MetaFrameCOM.MetaFrameLoadEvaluator"
$newle.LEName = $name
$newle.Description = $description
$newle.Rules = $allrules
$newle.SaveData()
Category:Scripting, Windows PowerShell | Comment (0) | Author: Frank-Peter