• View Communities
    • Citrix Developer Network
      The place for unfiltered straight talk on Citrix products. Blogs, code downloads, best practices, APIs, and more can all be found here.
    • Citrix Ready Community Verified
      Does it work with Citrix? Application compatibility questions are a thing of the past with the new Citrix Community Verified site.
    • Blogs
      Learn the latest from the Citrix employees who are building application delivery infrastructure technologies.
    • Blogosphere
      The Citrix Blogosphere is a window into the thousands of conversations taking place about Citrix and Application Delivery.
  •  Sign In
The Citrix Blog
Personal Blog
Christian Gehring

Microsoft Windows PowerShell command line shell and scripting language helps IT professionals achieve greater control and productivity. Using a new admin-focused scripting language, more than 130 standard command line tools, and consistent syntax and utilities, Windows PowerShell allows IT professionals to control system administration and accelerate automation more easily

With PowerShell, Citrix Administrators can script MFCom Objects to manage and administer  the XenApp Farm. The secret of using COM objects starts with the command: New-Object -COM.

The following PowerShell example creates a new MetaFrame object (do not get confused with the COM Object naming), initializes the Farm and prints out the farmname:

$farm = new-Object -com "MetaframeCOM.MetaframeFarm"
$farm.Initialize(1)
$farm.FarmName

It's not going to be a spectacular script. But look at the following little code enhancement:

$farm = new-Object -com "MetaframeCOM.MetaframeFarm"
$farm.Initialize(1)
$farm.FarmName
$farm.sessions | Format-Table UserName,ClientAddress

Just adding one more lines of code and you will get all sessions within the farm displaying the Username and IP Address.

Setting up your PowerShell / MFCom environment

Beginning  with PowerShell / MFCom Scripting you should install Microsoft Powershell on a Citrix Presentation / XenApp Server in your lab. I recommend downloading the PowerShell Graphical Helpfile which also provides great information's about VBScript to PowerShell conversion.

For creating and editing your PowerShell scripts I suggest downloading the free PowerGui graphical user interface and script editor. Its easy to use and works well with COM Objects.

PowerShell
http://www.microsoft.com/windowsserver2003/technologies/management/powershell/download.mspx

PowerShell Graphical Help File
http://www.microsoft.com/downloads/details.aspx?FamilyId=3B3F7CE4-43EA-4A21-90CC-966A7FC6C6E8&displaylang=en

PowerGui - Graphical user interface and script editor
http://www.powergui.org

Displaying apps in your farm

To give you some basic ideas where PowerShell leverages your daily administrative tasks, I've created the following script:
$farm = new-Object -com "MetaframeCOM.MetaframeFarm"
$farm.Initialize(1)
$farm.FarmName
$farm.applications| where {$_.BrowserName -like "Winword*" {color:black}} | select DistinguishedName

The script above enumerates each application published in the farm and selects all applications where Winword* is contained in the BrowserName.

PowerShell Examples provided by CDN

PowerShell and other scripting examples can be found on the Citrix Developer Network:

http://community.citrix.com/label/cdn/powershell

Labels

powershell powershell Delete
mfcom mfcom Delete
scripting scripting Delete
sdk sdk Delete
cdn cdn Delete
xenapp xenapp Delete
lang-eng lang-eng Delete
Enter labels to add to this page:
Please wait 
Looking for a label? Just start typing.
  1. Aug 12, 2008

    Anonymous says:

    PowerGUI admin console now has a PowerPack based on MFCOM - with all the scr...

    PowerGUI admin console now has a PowerPack based on MFCOM - with all the scripts in there available with their source code.

    1. Aug 12, 2008

      Vishal Ganeriwala says:

      PowerPack is cool. Thanks for putting this together. Vishalg

      PowerPack is cool. Thanks for putting this together.
      Vishalg

      1. Anonymous replies:

        You are not logged in. Any changes you make will be marked as anonymous. You may want to Log In if you already have an account. You can also Sign Up for a new account.

Add Comment