As I wrote in an earlier blog, there is an easy way to get the load in a RDS farm using powershell. The same thing can be done in a citrix environment.

It’s possible to do this using powershell, If you use workergroups to deploy applications, the following script can be used:

#add citrix cmdletsAsnp Citrix.*

#load all workergroups
$workergroups = Get-XAWorkerGroup

#Get the tmp folder location
$X= (Get-Item env:tmp).value
foreach ($wg in $workerGroups)
{
$currentWG = $wg.WorkerGroupName

#Write the current workergroup name to a temporary file:

add-content $x\users.log ” ”
add-content $x\users.log $currentwg

# in our case, we’re not interested in the all_servers worker group.
if ($currentwg -ne “All_Servers”)
{
foreach ($ServerName in $wg.Servernames)
{

# get all users using the quser command
$users = invoke-expression -Command “quser /server:$ServerName”
$number = $users | Select-String -Pattern “Active” |measure |select count
$t= $number.count

#get the memory values
$mem_value = Get-WmiObject -Class Win32_OperatingSystem -Namespace root/cimv2 -ComputerName $ServerName
$tm = ($mem_value.TotalVisibleMemorySize / 1048576)
$memTOT = ‘{0:N2}’-f $tm
$tm = ($mem_value.FreePhysicalMemory / 1048576)
$memFree = ‘{0:N2}’-f $tm
add-content $x\users.log “$ServerName `t users: `t $t `t Memory: $memTOT GB `t Free: $memFree”
}
}
}
notepad $x\users.log
ping localhost
del $x\users.log

I know, quser isn’t a powershell cmdlet, but it’s a command I know and it’s very fast. Anything that gets the job done quicker is alright in my book.

Categories: Citrix, Powershell

Leave a Reply

Your email address will not be published. Required fields are marked *