Tag Archives: MFCOM

Can I use the XenApp 6 Migration Tool on XenApp 6.5?

The XenApp 6 Migration Tool is a PowerShell 2.0 Module that pulls data from a MFCOM-based XenApp farm and adds it to a XenApp 6 server farm. As XenApp 6.5 is around now, including almost the same set of Cmdlets like its predecessor, it seems to be perfectly possible to use that Tool to migrate from XenApp 5 to XenApp 6.5 for example. So what’s the catch?

The answer is pretty simple: Citrix XenApp 6.5 has built-in migration capabilities which includes the former Migration Tool cmdlets. Therefore, don’t care about the past and take a closer look at the XenApp 6.5 Migration Center ;-)

The Migration Center is a PowerShell module and you can use it through a GUI or a command-line.

How To Remotely Administer A Citrix Farm From The PowerShell Prompt?

If you’re using Windows PowerShell to administrer and automate Citrix Farms the day will dawn when you ask yourself (or someone else) if it is possible to fire up the locally installed Windows PowerShell Console in order to perform a task against a Citrix Farm remotely. Yes, it is possible

In case of XenApp 6 you make use of PowerShell 2.0′s Remoting feature as follows:

#
# Remote XenApp 6 w/ PowerShell 2.0 Remoting
#
$CitrixServer = 'ctx001'

$session = New-PSSession -ComputerName $CitrixServer
Enter-PSSession -Session $session

Add-PSSnapin Citrix*

In case of MFCOM-based Legacy Farm Server you can either create a PowerShell Remoting Session like above or – if you still use PowerShell 1.0 you have no other choice – create a remote COM object:

#
# Remote MFCOM w/ PowerShell 2.0 Remoting
#
$CitrixServer = 'ctx001'

$session = New-PSSession -ComputerName $CitrixServer[activator]::CreateInstance($type, $null)
Enter-PSSession -Session $session

$farm = New-Object -ComObject 'MetaFrameCOM.MetaFrameFarm'

#
# Remote MFCOM w/ PowerShell 1.0 and .NET
#
$CitrixServer = 'ctx001'

$type = [type]::GetTypeFromProgID('MetaFrameCOM.MetaFrameFarm', $CitrixServer)

$farm = [activator]::CreateInstance($type, $null)

How To Migrate A “Legacy” Citrix Farm To XenApp 6?

Recently, I wrote here about the release of the Citrix XenApp 6 PowerShell SDK and that XenApp 6 neither supports nor contains the MFCOM programming interface of XenApp 5 and older versions (which I will call Legacy Farm from now on).

Upcoming Legacy Farm to XenApp 6 migration projects will definitely go along with the requirement to automatically export the Legacy Farm’s objects like Applications or Administrators in order to import them into the new XenApp 6 Farm. Since XenApp6 has no MFCOM support you won’t be able to use MFCOM based migration scripts you may have written for former migration projects. What you need instead is a Migration Tool that “speaks” both MFCOM and XenApp 6 Commands – meaning a tool that is able to communicate with the Legacy Farm as well as the new farm.

Good news is that such a tool is already available, currently it is still in Beta and it is supposed to be released in mid of this month – the Citrix XenApp 6 Migration Tool (Download)

The XenApp 6 Migration Tool contains a PowerShell 2.0 Module whose Cmdlets and Functions can be used to export Legacy Farm settings from a XenApp 5 Farm and import them to a XenApp 6 Farm. The following types of objects can be migrated:

  • Application
  • Folder
  • Load evaluator
  • Policy
  • Server configuration
  • Farm configuration
  • Administrator

Settings you can’t transfer:

  • Zones
  • Printer management
  • Configuration logging settings

The XenApp 6 Migration Tool supports only migration from a single XenApp 5 Farm. It isn’t possible to consolidate multiple Legacy Farms into one XenApp 6 Farm. The Legacy Farm must be based on XenApp 5 for WS2003 + HRP5 or XenApp 5 for WS2008. The new farm must be running XenApp 6 for WS2008 R2.

XenApp 6 PowerShell SDK Released

About two weeks ago Citrix has released the XenApp 6 PowerShell SDK that enables people to manage XenApp 6 farms using Microsoft PowerShell scripting. The modules included in the SDK are Citrix XenApp Commands (aka XenApp cmdlets), Citrix Group Policy Provider, and Citrix Common Commands. The Citrix Principal Design Engineer Tom M Kludy wrote some nice blogs about the XenApp 6 SDK.

Reading the XenApp cmdlets reference I found the following information for those of you who are familiar with MFCOM:

Starting in XenApp 6.0, MFCOM as a publically supported programming and scripting interface will no longer be available. All existing MFCOM-based code no longer works on XenApp 6.0. No doubt that the absence of MFCOM will be something that requires additional effort to the adoption of XenApp 6.0.

Take a deep breath and don’t panic! Most of MFCOM scripts can be replaced by one-liners meaning that most of the short MFCOM scripts are obsolete as they’ve been replaced by PowerShell cmdlets.

For example adding a Citrix admin with the XenApp 6 PowerShell SDK is a one-liner:

New-XAAdministrator –AdministratorName ctxadmin –AdministratorType Full

In MFCOM, an administrator would need to write a script with dozens lines of code like below to accomplish the same task. So after all, it was definitely a good idea to discontinue MFCOM Support.

function Test-IsCitrixAdministrator(){

    $MetaFrameWinFarmObject = 1

    $MFCOM = New-Object -ComObject 'MetaframeCOM.MetaFrameFarm'
    if (!$MFCOM)
    {
        $result = $false
    }
    else
    {
        $MFCOM.Initialize($MetaFrameWinFarmObject)
        $result = [boolean] $MFCOM.WinFarmObject.IsCitrixAdministrator
        $MFCOM = $null
    }
    $result
}


function Test-ADGroup(){

    param(
        $name = $(throw "No AD group name specified.")
    )

    $domainRoot = [System.DirectoryServices.ActiveDirectory.Forest]::GetCurrentForest().RootDomain.Name
    $searcher = New-Object System.DirectoryServices.DirectorySearcher([ADSI]"GC://$domainRoot")
    $searcher.Filter = "(&(objectClass=Group)(name=$name))"
    $result = $searcher.FindOne()
    [boolean] $result
}


function Add-CitrixAdmins(){

    param(
        $accounts = $(throw "No comma-seperated list of Citrix Admin accounts specified."),
        $adminType = $(throw "No Admin Type specified. (Full or ViewOnly?)")
    )

    $MetaFrameWinFarmObject     = 1
    $MFAdminPermissionViewOnly  = 1
    $MFAdminPermissionFullAdmin = 3
    $MFAccountAuthorityADS      = 3
    $MFAccountGlobalGroup       = 4
    $MFAccountEnable            = 1

    switch($adminType)
    {
        "Full"
        {
            $MFAdminPermission = $MFAdminPermissionFullAdmin
        }

        "ViewOnly"
        {
            $MFAdminPermission = $MFAdminPermissionViewOnly
        }

        default
        {
            throw "This function supports only the Citrix Admin Privilege levels Full and ViewOnly."
        }
    }

    $MFCOM = New-Object -ComObject 'MetaframeCOM.MetaFrameFarm'
    $MFCOM.Initialize($MetaFrameWinFarmObject)

     $currentAdmins = $MFCOM.Admins | %{$_.FriendlyName}
    $newAdmins     = $accounts.Split(",")

    $defaultDomain = $env:USERDOMAIN

    foreach($account in $newAdmins)
    {
        $newAdmin = $account.Split("\")
        if($newAdmin.Count -eq 1)
        {
            $accountDomain = $defaultDomain
            $accountName = $account
            if (-not (Test-ADGroup $accountName)){throw "Group does not exist in $accountDomain - $accountName"}
        }
        else
        {
            $accountDomain = $newAdmin[0]
            $accountName = $newAdmin[1]
        }

        if($currentAdmins -notcontains "$accountDomain\$accountName")
        {
            $mfAdmin = $MFCOM.AddAdmin()
            $mfAdmin.AdminType = $MFAdminPermission
            $mfAdmin.AAType = $MFAccountAuthorityADS
            $mfAdmin.AAName = $accountDomain
            $mfAdmin.AccountType = $MFAccountGlobalGroup
            $mfAdmin.AccountName = $accountName
            $mfAdmin.Enable = $MFAccountEnable
            $mfAdmin.SaveData()
            $mfAdmin = $null
        }
    }
}

Citrix XenApp Commands, Tech Preview 2

The Citrix XenApp Commands are PowerShell Cmdlets that allow command-line and script based managing of most aspects related to XenApp. The XenApp Commands cover MFCOM’s functionality for all XenApp 5 features that are usually managed with the consoles AMC and CMC.

This second Tech Preview of the XenApp Commands is open to everyone with a MyCitrix account (Download).

The XenApp Cmdlets are high quality, check it out and use the Citrix XenApp Commands Forum to report bugs, to request enhancements, to post useful scripts, general questions, whatever.

New Citrix MFCOM Scripting Guide

If you need to automate Citrix XenApp (formerly known as Presentation Server) download now the updated Ultimate Guide to MFCOM SDK by “Dr. SDK”

According Citrix Blogger Vishal Ganeriwala this is the only guide you will ever need to understand and learn about MFCOM SDK. It covers everything up to SDK version 4.5. It covers all the advance MFCOM topics such as multifarm management, publishing different type of Applications, policies, load evaluators and more.

All sample code in the new MFCOM guide is still written in VBScript.

According Dr. SDK Citrix is considering to develop a PowerShell-based interface to replace MFCOM entirely. Part of the reason for such a consideration is that most of the farm and server properties will be moved Active Directory. That will result in a large portion of MFCOM properties being invalid.

If you’re interested in scripting MFCOM with PowerShell see also: PowerShell and Citrix MFCOM recorded Webinar and Powerpoint slide deck.