Thursday, January 13, 2011

Disable ICA Load Evaluator

How to Take a XenApp Server Offline with Load Evaluator and Powershell 

Requirements: XenApp 4.5 or 5.0 with Hotfix Rollup Pack 06

Procedure : 

  •  In the XenApp Advanced Configuration console, right click the Load EvaluatorsNew Load Evaluator. node and select



  • Name your load evaluator and assign Scheduling as the only rule.




  • Remove all intervals from the scheduling rule. This prevents any server with this assigned rule from taking any connections.



    •  Once you have the offline Load evaluator created, you can use PowerShell ian a script or command line to take the server offline using the following PowerShell command:
      Set-XAServerLoadEvaluator [ServerNAme] [LoadEvaluatorName] 
    • To reset the server to the default load evaluator, use the following PowerShell command.
      Reset-XAServerLoadEvaluator [ServerName]

    Create the above Load Evaluator useing the below powershell script . Run the script useing ./Add-DisableICALogonLE.ps1 -name [Load_EvaluatorName]

    "
    # 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 http://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()

    "

    No comments:

    Post a Comment