Did you ever want to fully automate your XenApp 6.5 farm? Did you manage an automated unattended installation or image, but you are struggling to automate farm configurations? Would you like to learn how to create and configure load evaluators for XenApp 6.5 with PowerShell? In this case, this article is just for you.
Automating Citrix consists of various components. You need to configure:
- Citrix administrators
- Citrix worker groups
- Citrix user and computer policies
- Citrix load evaluators (explained in this article)
Note: see the article PowerShell Fundamentals if you are new to PowerShell or if you just want to refresh your memory. Especially important is the part about loading snap-ins and modules. Remember, the appropriate extensions need to be loaded before Citrix commands can be executed! |
Creating and configuring Citrix load evaluators using PowerShell
Citrix installs two load evaluators by default: Default and Advanced. Additional custom load evaluators are easily created using PowerShell.
To give you an example. Let’s create a custom load evaluator which sets the maximum CPU load to 90, the maximum RAM usage to 90 and the maximum number of concurrent user (server user load) to 50. This is the command:
1 |
new-XALoadEvaluator "CustomLE1" -Description "CustomLE1" -CpuUtilization 10,90 -MemoryUsage 10,85 -ServerUserLoad 50 |
And that’s it! Life sometimes really is that simple. So what other values can we configure? Here is the complete list:
- Application user load:
Specify the maximum application user load and the application name to which this setting applies (e.g. -ApplicationUserLoad 20 -ApplicationBrowserName “Notepad”). - Context Switches:
Enter two values: one where there is considered to be no load and one specifying the maximum load (e.g. -ContextSwitches 900,16000). - CPU Utilization:
Enter two values: one where there is considered to be no load and one specifying the maximum load (e.g. -CpuUtilization 10,90). - Disk Data I/O:
Enter two values: one where there is considered to be no load and one specifying the maximum load (e.g. -DiskDataIO 0,32767). - Disk Operations:
Enter two values: one where there is considered to be no load and one specifying the maximum load (e.g. –DiskOperations 0,100). - IP Range:
IP ranges can be allowed and denied. To enter an IP range and set it to “allow” use the following parameters: -IPRanges 192.168.0.10-192.168.0.100 -IPRangesAllowed $True. To deny the same range use: -IPRanges 192.168.0.10-192.168.0.100 -IPRangesAllowed $False. - Load Throttling:
Manage the impact of logon on the load. Possible values are Extreme, High, MediumHigh, Medium,and MediumLow. The default value is High. Configure a different value like this: -LoadThrottling MediumHigh. - Memory Usage:
Enter two values: one where there is considered to be no load and one specifying the maximum load (e.g. –MemoryUsage 10,90). - Page Faults:
Enter two values: one where there is considered to be no load and one specifying the maximum load (e.g. –PageFaults 0,2000). - Page Swaps:
Enter two values: one where there is considered to be no load and one specifying the maximum load (e.g. –PageSwaps 0,100). - Scheduling:
Set a scheduling rule when logons to the servers are permitted. The parameter must be specified using the format StartTime-EndTime. The times are specified in the 24-hour format HH:MM. For every day in the week a separate parameter exists.
For example, to allow logons from Monday to Friday from 8 o’clock in the morning until 6 o’clock in the evening enter -MondaySchedule 08:00-18:00 -TuesdaySchedule 08:00-18:00 -WednesdaySchedule 08:00-18:00 -ThursdaySchedule 08:00-18:00 -FridaySchedule 08:00-18:00. The two remaining parameters are: -SaturdaySchedule and -SundaySchedule. - Server User Load:
Specify the maximum number of users which can be logged on to the Citrix server at the same time. For example: -ServerUserLoad 50.
Did you know that you can use the scheduling option to disable a Citrix server? What you do is you create a load evaluator and add the scheduling option. Then set the logon times of each day to zero, which means that there is no allowed logon window for users. This basically disables the server since users are not allowed to logon at any time.
Please be aware that this applies to the ICA protocol only! If standard users are allowed to connect to a Citrix server via RDP, which is not recommended, the new Citrix load evaluator will not prevent this.
The command for this is:
1 |
New-XALoadEvaluator "Disabled" -Description "Disable servers" -MondaySchedule 00:00-00:00 -TuesdaySchedule 00:00-00:00 -WednesdaySchedule 00:00-00:00 -ThursdaySchedule 00:00-00:00 -FridaySchedule 00:00-00:00 -SaturdaySchedule 00:00-00:00 -SundaySchedule 00:00-00:00 |
One other thing. The command New-XALoadEvaluator can only be used to create (and configure) a new load evaluator. To configure an existing load evaluator use the command Set-XALoadEvaluator.
The following script creates two load evaluators, “Enabled” and “Disabled”. The “Enabled” load evaluator configures the CPU and RAM utilization and Load Throttling. The “Disabled” load evaluator does not allow any logon times.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 |
#========================================================================== # CREATE AND CONFIGURE CITRIX LOAD EVALUATORS # # AUTHOR: Dennis Span (https://dennisspan.com) # DATE : 15.12.2013 # Scripting language: PowerShell (v.2.0) # # COMMENT: This script creates and configures two Citrix load evaluators: # "Enabled" and "Disabled" #========================================================================== # Logging: # "-" = comment # "I" = information # "S" = success (action successful) # "E" = error (action unsuccessful) # Set the error action preference to "stop" to ensure that the try and catch statements work for non-terminal errors $ErrorActionPreference = "Stop" # ================================================= # Configure variables $ComputerName = $env:ComputerName # Define the environment variable "ComputerName" # ================================================= # ================================================= # Load all Citrix cmdlets # ================================================= Add-PSSnapin citrix* # ================================================= # Task 1 of 2: Create and configure the load evaluator "Enabled" # ================================================= # Define the name of the load evaluator this script should create $LEName = "Enabled" # Provide a description for the load evaluator $LEDescription = "Enable server" Write-Host ("I - Create and configure the load evaluator $($LEName.ToUpper())") try { Get-XALoadEvaluator $LEName | Out-Null Write-Host ("I - The load evaluator already exists") Write-Host ("I - Configure load evaluator") try { Set-XALoadEvaluator $LEName -CpuUtilization 10,90 -MemoryUsage 10,90 -LoadThrottling "MediumHigh" | Out-Null Write-Host ("S - The load evaluator $($LEName.ToUpper()) has been configured successfully") } catch { Write-Host ("E - Configuring the load evaluator $($LEName.ToUpper()) ended in an error") } } catch { Write-Host ("I - The load evaluator does not exist") Write-Host ("I - Creating and configuring the load evaluator...") try { New-XALoadEvaluator $LEName -Description $LEDescription -CpuUtilization 10,90 -MemoryUsage 10,90 -LoadThrottling "MediumHigh" | Out-Null Write-Host ("S - The load evaluator $($LEName.ToUpper()) has been created and configured successfully") } catch { Write-Host ("E - Creating and configuring the load evaluator $($LEName.ToUpper()) ended in an error / " + $error[0]) } } Write-Host ("") # ================================================= # Task 2 of 2: Create and configure the load evaluator "Disabled" # ================================================= # Define the name of the load evaluator this script should create $LEName = "Disabled" # Provide a description for the load evaluator $LEDescription = "Disable server" Write-Host ("I - Create and configure the load evaluator $($LEName.ToUpper())") try { Get-XALoadEvaluator $LEName | Out-Null Write-Host ("I - The load evaluator already exists") Write-Host ("I - Configure load evaluator") try { Set-XALoadEvaluator $LEName -MondaySchedule 00:00-00:00 -TuesdaySchedule 00:00-00:00 -WednesdaySchedule 00:00-00:00 -ThursdaySchedule 00:00-00:00 -FridaySchedule 00:00-00:00 -SaturdaySchedule 00:00-00:00 -SundaySchedule 00:00-00:00 | Out-Null Write-Host ("S - The load evaluator $($LEName.ToUpper()) has been configured successfully") } catch { Write-Host ("E - Configuring the load evaluator $($LEName.ToUpper()) ended in an error") } } catch { Write-Host ("I - The load evaluator does not exist") Write-Host ("I - Creating and configuring the load evaluator...") try { New-XALoadEvaluator $LEName -Description $LEDescription -MondaySchedule 00:00-00:00 -TuesdaySchedule 00:00-00:00 -WednesdaySchedule 00:00-00:00 -ThursdaySchedule 00:00-00:00 -FridaySchedule 00:00-00:00 -SaturdaySchedule 00:00-00:00 -SundaySchedule 00:00-00:00 | Out-Null Write-Host ("S - The load evaluator $($LEName.ToUpper()) has been created and configured successfully") } catch { Write-Host ("E - Creating and configuring the load evaluator $($LEName.ToUpper()) ended in an error / " + $error[0]) } } |
When the script finishes you should see two additional load evaluators in the Citrix console:
Related articles:
- Automating XenApp 6.5 Part 1 of 4 – Citrix Administrators
- Automating XenApp 6.5 Part 2 of 4 – Citrix Worker Groups
- Automating XenApp 6.5 Part 3 of 4 – Citrix Policies
- PowerShell “one-liners” for Citrix XenApp 6.x
Dennis Span works as a Lead Account Technology Strategist at Cloud Software Group in Vienna, Austria. He holds multiple Citrix certifications (CCE-V). Dennis has been a Citrix Technology Advocate (CTA) since 2017 (+ one year as Citrix Technology Professional, CTP). Besides his interest in virtualization technologies and blogging, he loves spending time with his family as well as snowboarding, playing basketball and rowing. He is fluent in Dutch, English, German and Slovak and speaks some Spanish.