Posts RSS Comments RSS 130 Posts and 202 Comments till now

How to Manage Multiple Citrix Farms

Chris left a comment on Powershelling Citrix (The Good, Bad, and The Code)

Here is a function that returns a farm object for Server that is passed.

function Get-CitrixFarm {
   Param([string]$server)
   $type = [system.Type]::GetTypeFromProgID("MetaframeCOM.MetaFrameFarm",$server)
   $farm = [system.Activator]::CreateInstance($type)
   $farm.Initialize(1)
   return $farm
}
 

Here is an example to find a Server that a User is on.

function Find-CitrixUser {
    Param([string]$user,[string]$server,[string]$domain,[switch]$verbose)
    $type = [system.Type]::GetTypeFromProgID("MetaframeCOM.MetaframeUser",$server)
    $mfuser = [system.Activator]::CreateInstance($type)
    $mfuser.Initialize(1,$domain,1,$user)
    Write-Host
    Write-Host "User: $($mfuser.UserName) found on the Following:"
    foreach ($s in $mfuser.Sessions)
    {
        if($verbose)
        {
            Write-Host
            Write-Host "$($s.ServerName)"
            Write-Host "-=-=-=-=-=-"
            Write-Host "AppName          : $($s.AppName)" -foregroundcolor yellow
            Write-Host "SessionName      : $($s.SessionName)" -foregroundcolor yellow
            Write-Host "SessionID        : $($s.SessionID)" -foregroundcolor yellow
            Write-Host "ClientAddress    : $($s.ClientAddress)" -foregroundcolor yellow
            Write-Host "ClientEncryption : $($s.ClientEncryption)" -foregroundcolor yellow
            Write-Host
            Write-Host "Processes"
            Write-Host "========="
            foreach ($proc in $s.Processes)
            {
                Write-Host $proc.ProcessName -foregroundcolor Green
            }
            Write-host
        }
        else
        {
            write-Host "   -> $($s.ServerName)"
        }
    }
}

No Responses to “How to Manage Multiple Citrix Farms”

  1. on 14 Jul 2007 at 5:23 pmChris

    You really really helped me out when you put the multi-farm thing together. I took that seed and wrote an expanded function called Get-CTXFarm that I thought you might like to check out. I yet to run a field test, but I built each section after figuring out the bits live so I am pretty sure it will work. Please let me know your feedback. Here is the link: http://merddyin.spaces.live.com/

Trackback this post | Feed on Comments to this post

Leave a Reply

CAPTCHA image