Load Balancing Auto-Configuration for SAP using Workflow Studio and NetScaler
At the tail end of our certification process at SAP, Citrix engaged in a unique opportunity to make use of the SAP APIs, using Workflow Studio to auto-configure the Citrix NetScaler for Load Balancing. The way it works is, Workflow Studio polls the SAP API, reads the response, and then based on the results in the response, configures the NetScaler Load Balancing groups that map directly to the SAP servers running in the server farm.
SAP has a community group dedicated to the development of their APIs, please reference the latest blog post Catching Up with Deployment and Operations Automation, describes the SAP APIs.
The SAP Community Definition Group (CDG) - titled "PCDG 97 NetWeaver Infrastructure APIs for Network Solutions" - is focused on automation of network-application integrated configuration and operation. As the group title implies, the SAP NetWeaver technology platform includes APIs, which are used by the NetScaler ADCs (load balancers) to auto-configure themselves as proxies for multi-instance SAP application systems. Using Citrix Workflow Studio, the SAP APIs are polled on a regular basis so that the NetScaler ADCs can react to SAP application instance changes during production runtime.
If another application instance is brought up, let's say for providing more computing capacity for an increasing end-user load, or if an instance is brought down temporarily for maintenance, Workflow Studio communicates with the NetScaler ADC to adjust load balancing automatically without any manual administrator intervention. There is no more wait, or lengthy change management required to provision applications.
Workflow Studio, NetScaler and SAP API Use Cases:
Use Case 1: (auto-configure new SAP services).
Workflow Studio sends a URL request to the SAP Message Server, and receives a response. Workflow Studio parse's the response, looking for specific SAP generated patterns. WFS then uses this information to configure a Load Balancing Virtual Server inside of the Citrix NetScaler.
Use Case 2: (dynamic configuration).
Workflow Studio repeatedly queries the SAP API. WFS studio can determine hostnames, ip addresses, port numbers, and whether an SAP server is coming online or going down. When a SAP server comes online/goes down - WFS detects this change, and then takes action on the Citrix NetScaler, to add/remove the SAP service from the Load Balancing group - automatically.
Use Case 3: (graceful shutdown).
Workflow Studio queries the SAP API, determines a SAP server is going down, and based on the response, waits until all existing sessions have been retired, before removing the server from the Load Balancing group . During the shutdown period, no new sessions are added to that SAP server, providing a graceful shutdown of the SAP service. This way, there are no TCP resets sent to existing sessions. New logins are routed to a different server.
Read the SAP article here.
Tap into the power of AppExpert!
We had a question on the support forums about modifying the database used for Workflow Studio, which defaults to 'WFDB'. All the SQL scripts are provided for you in the Workflow Studio install, and we anticipated our customers wanting to have multiple databases on a single server or just changing the name from the default 'WFDB' name. In fact, if the SQL Admin wants more control they can customize as much as needed.
I wrote up an article to cover the process:
http://community.citrix.com/display/wf/Customizing+Your+Workflow+Studio+Database
If anyone tries this and runs into problems let me know
I have a lot of ideas for posts that I think will only be interesting to the software developer - the third audience of Workflow Studio. I started wondering just how many people reading this blog would consider themselves to fall into this category. Go back and read the post on the Three Audiences of Workflow Studio and then vote here to tell me which group you fall into. If you cross over more than one of them, pick the one you are most interested in reading about.
| Which audience are you? | Choose |
|---|---|
| IT Operations | |
| Server Administrator | |
| Software Developer |
In my last post I told you about the breakout session on Workflow Studio I will be doing and I hope to see you there:
http://community.citrix.com/x/FYG1Aw
If you are coming to Synergy I will also be hosting a Learning Lab on Workflow Studio and Citrix Receiver. The Learning Lab format gives us 3 hours to dive into the details, so if you want to learn more about building workflows to orchestrate the Delivery Center - sign up now!
Here are the details:
Title: Hands-on with the Citrix Delivery Center - featuring Workflow Studio orchestration and Citrix Receiver
Session Number: iForumLL706
Track(s): Learning Labs
Room: Premier Ballroom 306
This workshop provides attendees a chance to get hands-on experience with Receiver and Workflow Studio in a Citrix Delivery Center environment. Attendees will gain a deeper understanding for the architecture of these products and best practices for deploying them. Attendees will learn how to create and configure workflows that orchestrate functionality like power management, user provisioning, dynamic resource allocation, disaster recovery and product automation. Attendees will also learn how to configure the Receiver and leverage it to easily provide user access to applications and desktops—simplifying client management for IT.
Prerequisites:
Basic understanding of Citrix XenApp, Citrix NetScaler and Windows administration.
Students are required to bring their own laptops.
This session is held:
• Tuesday, May 5 at 11:30 a.m.
• Tuesday, May 5 at 3:00 p.m
• Wednesday, May 6 at 11:30 a.m.
• Wednesday, May 6 at 3:00 p.m.
I will be speaking about Workflow Studio at the upcoming Citrix Synergy event. Come by and here about what is coming next with Workflow Studio and if you have ideas for things you want covered, post them here or email me.
Here are the details:
Title: Go with the flow - Workflow Studio simplifies IT management and reduces costs
Session Number: iForum207
Track(s): iForum
Date / Time: May 7, 10:00 am - 10:50 am
Room: Premier Ballroom 310
According to industry analysts, 80 percent of unplanned downtime is due to "people failures" and 80 percent of IT budgets are spent just keeping the business running. Citrix Delivery Center simplifies IT by eliminating manual processes that are labor intensive and error prone with Workflow Studio, a process automation solution that enables you to compose, integrate and orchestrate rule-based workflows across your IT infrastructure. Power management, dynamic resource allocation and disaster recovery are just a few of the solutions that can be automated using Workflow Studio. Go with the flow and turn your IT infrastructure into a dynamic delivery center.
In this session you will learn:
• What Workflow Studio is and how it works
• How to build workflows that reduce power usage and maximize server utilization
• How to integrate Workflow Studio with your management systems
I just posted a video tutorial on using the Workflow Studio SDK to to convert a PowerShell cmdlet to an activity library on the Multimedia section of the Workflow Studio CDN site
This tutorial walks you through creating an activity library from the Get-Date PowerShell cmdlet just like the tutorial in the Developer's guide. The SDK and Developer Guide is available here:
http://community.citrix.com/cdn/wf/sdks
Here is the video:
Getting Started with the Workflow Studio SDK
Get started converting your own favorite PowerShell cmdlets and let us know what you find.
In my post on the "Three Audiences of Workflow Studio" I tried to explain how different features of Workflow Studio are used by different audiences. With the release of our Developer Toolkit we now also have 3 tutorials available that correspond to the 3 audiences:
- IT Operations - There is a tutorial available from the main Workflow Studio console (the Management console) on the Help...Getting Started menu that walks you through the process of downloading a workflow, importing it, and then scheduling it to run.
- Server Administrator - There is a tutorial available from the Workflow Studio Designer on the Help...User Guide menu that walks you through the process of creating the same workflow that is available for download above.
- Software Developer - There is a tutorial available in the Developer's Guide that walks you through the process of creating new activity libraries - both converting from PowerShell and writing from scratch.
The first two tutorials that are available within Workflow Studio are also part of a larger User's Guide that is available on the product download page.
The final tutorial is available on the SDK download page.
We have just released a developer toolkit that will make creating activity libraries much easier. This toolkit contains a set of templates for Visual Studio and a PowerShell Converter utility. With the PowerShell Converter you can automatically generate an activity library from any PowerShell snap-in that you have installed. You can download it here:
http://community.citrix.com/cdn/wf/sdks
If you are a part of the Software Developer audience for Workflow Studio you definitely want to check this out. If you have comments or questions you can use the Activity Library Development forum.
***Update: As of the 2.0 release we now include 143 activities with the product, including libraries for Netscaler, XenServer, and XenApp. We keep adding more, and if you have specific requests, please email me...
Alex posted in our forums that he was extremely disappointed in the 1.0 release of Workflow Studio because of a lack of libraries/templates for use with Citrix products. We are working on releasing libraries for Citrix products, as well as libraries that integrate with Active Directory, Group Policy, Power Management, and Windows. I appreciate the criticism, as it made me realize that we haven't done a good job of describing the target audience of this 1.0 release. I would like to take the opportunity to explain the different audiences that Workflow Studio appeals to, and why we released 1.0 as it is. Hopefully this post will help to explain how the different features of Workflow Studio appeal to these audiences and also clarify how it can be used today and where we are going in the future.
To make sure we are all on the same page, I want to start by defining the audiences that I will refer back to later. The titles I chose are not important, but hopefully the descriptions will help you to place where this fits in your organization. In the IT industry people often wear many hats and don't fit neatly into a classification.
- IT Operations - This role is responsible for ensuring that IT systems are working and available on a wide scale, but would not typically do development or scripting tasks.
- Server Administrator - This role is responsible for specific server workloads and is intimately familiar with the software running on a system. They are comfortable with batch files, scripting, PowerShell, etc. but would not be comfortable doing traditional software development.
- Software Developer - This role is defined by people who write software that is either sold (Software Companies, System Integrators, Consultants, etc.) or used internally by other groups (often including the above two audiences.)
Workflow Studio is built on top of two technologies from Microsoft - Windows PowerShell and Windows Workflow Foundation. Linking these technologies to the audiences from above for PowerShell would be the Server Administrator, and for Workflow Foundation would be the Software Developer. Our intent with Workflow Studio is to merge these two technologies together and offer solutions that appeal to the IT Operations staff (and Server Administrators who are looking for tools, but are too busy to script solutions to all their needs themselves.) As a result of being built on top of PowerShell and Workflow Foundation, we offer features that the other two audiences will also find useful.
As Alex pointed out, the 1.0 release is not very interesting to the IT Operations audience yet because there isn't a large base of activity libraries and workflows available today. The Software Developer audience on the other hand can use 1.0 today with the publicly available APIs for our Citrix products (and if they choose, share or sell their work to the community at large.)
Now I want to take a look at specific features and functionality of Workflow Studio and how they map to these audiences:
IT Operations
The intended process of using Workflow Studio for this audience would be to download workflows (and activity libraries) that solve specific problems that this audience faces. All that needs to be done after downloading the workflows is to schedule or execute them as applications that solve those specific needs.
Workflow Studio has a community tab that links the product back to the Citrix Developer Network (CDN). Citrix, our partners, and the community at large can post activity libraries and workflows that can be downloaded and used without any need to write scripts or code. We built in a tutorial workflow called ExportServices that you can access through the Help menu to see how this process is intended to work. We plan to leverage this mechanism to release activity libraries and workflows to address specific problems faced in deploying the Citrix Delivery Center and the Citrix Cloud Center. We are also looking to our partners and community to build additional libraries and workflows that this audience will find valuable.
Obviously, this audience will not be well served until pre-built workflows are available that solve problems you face in your environment. Let me know in the comments or through email what types of things you would like to see. As we release activity libraries we will also release workflows that relate to them and as more are available we will be able to release more integrated workflows as well.
Server Administrator
The intended use case for this audience is to build and modify workflows using the Workflow Studio Designer for use either internally or to share with the community.
We are working on some activity libraries that will be available in coming weeks that will facilitate building workflows that leverage your existing VBScript and PowerShell scripts. This functionality will enable this audience to leverage their existing scripting knowledge in a more visual, database-driven, automatically versioned, and easily share-able way. Workflows can be extended through C# with the code-beside feature, so if you know a little bit of programming you can automate almost anything that .NET and C# will allow with just the Designer and not need to go into Visual Studio to build native activity libraries. We have built in some pretty powerful extensions to Workflow Foundation in our Designer that will help you be more productive and make it easy to share within your group, organization, or the community. For instance, the snippets functionality allows you to save templates of individual activity configurations or groups of activities and then export and reuse/share them. Workflows themselves can also be exported and reused/shared as well. The Workflow Studio Designer is accessed by either creating a New Workflow or editing an existing workflow. You can also download other workflows and edit them to see how they were built.
This audience needs activity libraries available, and we are working on several that will be released in coming months. Active Directory, Group Policy, Windows, Power Management, and Citrix product support are all coming soon, so stay tuned.
Software Developer
The intended use case for this audience is to build and share/sell activity libraries that the above two audiences will find useful. These can target Workflow Studio directly or target Workflow Foundation more generically as the vendors in my post on Workflow Studio Extensibility have done.
Activity Libraries are the mechanism for extending Workflow Studio. An activity library is a component defined by Microsoft as part of Workflow Foundation. These can be built without any knowledge of Workflow Studio (standard Workflow Foundation activity libraries), but there are some features of Workflow Studio that we think offer additional value. We make it easy to target Workflow Studio directly with a set of templates for Visual Studio. Specifically, we have a converter that will take existing PowerShell snap-ins and convert them to activity libraries automatically. You will soon be able to download these templates and documentation on automating Workflow Studio on our Download SDKs page.
Workflow Foundation and PowerShell have been around now for more than 2 years. These technologies are robust and stable and can easily be leveraged with the 1.0 release of Workflow Studio. If you are a Citrix partner (or want to be one) and have some ideas in this space, feel free to contact me to discuss.
Hopefully this will help clarify where we are with Workflow Studio and where we are going. Feel free to email me with comments or thoughts on how we can do a better job of addressing your needs with Workflow Studio - whichever audience you may fall into.
Workflow Studio leverages product SDKs to accomplish automation, so I want to take a moment to remind everyone that each of the Citrix products has their own SDK page on the CDN:
- XenApp - http://community.citrix.com/cdn/xa/sdks
- XenServer - http://community.citrix.com/cdn/xs/sdks
- XenDesktop - http://community.citrix.com/cdn/xd/sdks
- NetScaler - http://community.citrix.com/cdn/ns/sdks
Notice the similar link on the Workflow Studio page? Stay tuned...
One of the great features of Workflow Studio is that it is designed to be extended. You can build your own activity libraries that add additional graphical objects to the product. The Activity Library standard was created by Microsoft and first hit the scene with the .NET Framework 3.0 release back in Nov. 2006. I did a little searching and found three companies that are offering activity libraries for sale. If you are looking for integration with FTP, ZIP, GZIP, TAR, SSH, and more into your workflows these companies might just save you some time:
- Xceed Activities for WF
- Eldos SecureBlackbox for Business Servers (Workflow Foundation edition)
- /n software Workflow Activities V3
Looking at the feature descriptions, the /n software product really stands out. In addition to FTP and ZIP activities, it has activities that natively support email, paging, RSS, and Instant Messaging. I can think of some good uses for all those communication types when a workflow detects something in the data center that needs my attention immediately. Even more intriguing though is that they have an Amazon S3 activity - automatic backups to the cloud anyone?
The Workflow Studio section of the Citrix Knowledge Center is now live:
http://support.citrix.com/product/wfs/v1.0/
The Knowledge Center is a great resource for all Citrix products and technologies. In fact, there is already a TechNote posted on how to manually edit global parameters through code in Workflow Studio. Gives me an idea for a series of blog posts... ![]()
Workflow Studio includes two tutorials that can be accessed from the Help menu. When you first launch Workflow Studio, you are in the management console:

The first tutorial can be accessed by clicking on the "Help...Getting Started" menu option. This will launch the Getting Started guide which is a tutorial that will walk you through the process of downloading a sample Workflow called ExportServices from CDN (using the built-in Community tab) and then running that workflow from the management interface.
Note: The tutorial is in PDF format. On many systems nothing will happen when you click on the "Help...Getting Started" link if you don't already have a PDF viewer already installed. Sorry about that - we will fix that in the next release.
The second tutorial is available from the Designer interface. The Designer interface is what is used to create or edit a workflow and looks very similar to the Tech Preview user interface:

This tutorial will take you through the process of creating the sample workflow that you saw in the first tutorial. This will demonstrate many of the techniques you will use to build workflows.
If you have any questions on either of these tutorials - post them here. In a future post I will explain some more details behind the Designer interface. Look for more tutorials and samples soon as well.
Rather than keep these blog posts updated with corrections and additions, I posted the entire installation guide in one piece as an article on the CDN site:
http://community.citrix.com/x/NQFOAw
One nice feature is that you can export the file to a PDF or Word document if you are logged into your MyCitrix account. Try it out and let me know what you think...
Workflow Studio 1.0 was released this week and is now available for download on MyCitrix to current Citrix partners, and to customers of XenApp, XenDesktop, XenServer, and NetScaler who are current on Subscription Advantage. You can access the download directly here. The Workflow Studio platform will allow our customers and partners to automate processes across Citrix products and with 3rd party products, truly delivering on the vision of transforming a datacenter into a delivery center. I am excited about this release and look forward to seeing what the community thinks and what ideas you have.
Citrix Partners can drive huge value to customers by developing custom Workflows using Citrix Workflow Studio. From automating routine manual processes like User Administration to more powerful integrated processes like Power Management, solutions can be built that are tailored to specific business requirements. Since WFS is built on Microsoft technologies, Partners can quickly ramp up to speed and staff resources to develop workflows in a very short period of time.
I apologize for the long break in my blog, but you can expect much more from me now that we have released. This release has some fairly significant changes/additions from the Tech Preview that I want to highlight here:
- Built on Windows Workflow Foundation - We have modified the architecture from what was in the Tech Preview so that now we leverage Workflow Foundation. Workflow Foundation is a technology that Microsoft released with .NET 3.0 and updated in .NET 3.5. This is a big change that we believe offers significant benefits to our customers as you will be able to leverage existing activity libraries from Microsoft and others. We also benefit from continued development of the platform by Microsoft and if you have developers working with Workflow Foundation they will be able to easily pick up Workflow Studio.
- Database-driven - We now require a SQL Server to store workflows. The benefit to you is that we automatically version your Workflows for you, so your workflows are no longer lost in your file system. Our installer will install SQL Server 2005 Express if you don't have or don't want to use a shared SQL Server.
- Job Management - Workflows can now be managed, monitored, scheduled, and run from within the Workflow Studio management interface. This functionality is also exposed via PowerShell snapins, giving you complete control of how workflows are run.
- Integrated Security - There is now built-in security settings that provide granular control over what a Workflow Studio user can do with a workflow.
- Integrated Community Support - Workflow Studio is a platform that our community can add value to in many ways. Sharing your experiences, sample workflows, activity libraries, and feedback will be a critical part of the Workflow Studio experience. We built in native integration with some of the sections of the Citrix Developer Network on the Community tab within the management interface.
I also want to highlight that this release does not include many of the libraries for accessing Active Directory, Windows, and Citrix products that were included in the Tech Preview. One of the things we did for this release was intentionally separate the Core product from the libraries that you add to access other systems. We will be releasing these libraries over the coming months for download and you will be able to select which modules you want to add as necessary. In addition to Citrix libraries, you will be able to add any standard Workflow Foundation Activity Library, and can build your own as well. I will be blogging more about these capabilities as I think this is a huge value for our customers and our partners.
The Citrix Desktop Delivery Controller PowerShell SDK provides a snap-in, XDCommands, for the Microsoft PowerShell v1.0 framework. The SDK consists of a number of "cmdlets" that allow you to script many of the administrative tasks you may need to perform on a regular basis.
Step by Step setting up your PowerShell / XenDesktop environment
- Install PowerShell 1.0 on the DDC (Desktop Delivery Controller)
- Download and Install Microsoft .NET Framework 3.5
- The PowerShell SDK is located on the XenDesktop 2.1 CD in the ...\Support\DdcSdk folder. Run the installer XenDesktop_2_0_DDC_Powershell_SDK.msi
Installing the SDK registers the XdCommands snap-in assembly with the Microsoft PowerShell framework. The snap-in makes a number of new classes and "cmdlets" available to PowerShell scripts or interactive shell sessions.
To run scripts you may need to use the built-in "Set-ExecutionPolicy" cmdlet to adjust the PowerShell execution policy to a value such as "RemoteSigned"
- Start Powershell and set the Excecution Policy. Set-ExecutionPolicy RemoteSigned
- Change to the folder where the SDK is installed cd \Program Files\Citrix\Desktop Delivery Controller\Powershell
- Load the snap-in into the PowerShell Add-PSSnapin XdCommands
Alternatively, use the installed PowerShell console file, XdCommands.psc1, to start an interactive PowerShell shell session with the XdCommands snap-in pre-loaded. Citrix provides a shortcut on the Start menu to start such a session. This shortcut also runs the "XdAliases.ps1" PowerShell script that sets up aliases for most of the SDK cmdlets. This shortcut will not function properly until the PowerShell execution policy, as described above, is set appropriately.
Help
Online help is available for all Desktop Delivery Controller SDK cmdlets. To obtain a list of cmdlets offered by the snap-in, run the built-in "Get-Command" cmdlet, as follows: Get-Command -psSnapin XdCommands
Online help for individual cmdlets is available using the built-in "Get-Help" cmdlet. For example, to view the online help for the "Get-XdDesktopGroup" cmdlet, run the following command: Get-Help Get-XdDesktopGroup
For an overview of all cmdlets provided by the SDK, view the "about_XdCommands" help topic. To view this information, run the following command: Get-Help about_XdCommands
Samples
Creating a new VM-based desktop group
This command creates a new VM-based desktop group, "testgrp", containing three machines, and published to all domain users. $usr = New-XdUser 'domain users' -group $cred = Get-Credential 'root' $hs = New-XdHostingServer 'XDS01' $cred $machineName= 'machine1','machine2','machine3' #find all the VM machines in the pool $allvms = Get-XdHostedMachine $hs #Find the workers and set the AD identity to the correct machine $dsk = $machineName | foreach { $vm=$_; $allvms | where {$_.HostingName -match $vm } | foreach { $_.Name = $vm; $_ }} $hgs = New-XdGroupHostingSettings $hs $ng = New-XdDesktopGroup -pub 'testgrp' -desk $dsk -user $usr -hosting $hgs
Adding a virtual desktop to an existing VM-based desktop group
This command adds a new virtual desktop, hosted by a VM, to an existing VM-based desktop group. Before adding a VM to the group, you must create a mapping between the VMs host ID and Active Directory ID. To do this, run the Get-XdHostedMachine cmdlet to obtain a list of host IDs for VMs and assign Active Directory IDs to those VMs.
# get all the groups whose name starts with 'test' (should be just one) $grp = Get-XdDesktopGroup test* # get all the workers whose friendly names have 'machine3' in them (should be just one) $dsk= Get-XdHostedMachine $grp.HostingSettings.HostingServer -name *machine3* # Set up the mapping to the AD name for the new Virtual Desktop machine $dsk.Name = 'machine3' $grp.Desktops.Add($dsk) Set-XdDesktopGroup $grp
If host ID to Active Directory ID mappings have been created previously, run the following command:
Get-XdDesktopGroup test* | *%* { \[void\]$\_.Desktops.Add($(Get-XdHostedMachine $\_.HostingSettings.HostingServer \-name \*machine3\*)); $\_ }| Set-XdDesktopGroup
Logging off a user from all current sessions, after sending a warning message
This command displays a warning message to all users whose names start with "christian" before logging them off. Note that in this example there is specified time period (10 seconds) before logoff occurs.
# get sessions for all users whose names start with 'christian'
$sess = Get-XdSession -user christian*
# warn the user
Send-XdSessionMessage $sess 'Forced log off in 10 seconds'
Start-Sleep 10
#Then go ahead with the logoff
Stop-XdSession $sess
Adding a user to an existing desktop group
This command adds users in all groups whose names match "GroupName" to an existing desktop group.
# get all the groups whose name matches 'GroupName' (should be just one)
# Note could also be written as:
# $grp = Get-XdDesktopGroup GroupName
$grp = Get-XdDesktopGroup | ? {$_.Name -match "GroupName" }
$Usr = New-XdUser "UserName"
$grp.Users.Add($Usr)
Set-XdDesktopGroup $grp
In my last blog I have started with the Introduction of PowerShell and MFCom. Today we'll provide you more information's about MFCom Objects and how to use them with PowerShell.
Check Session State
To retrieve the session state for each session within the Citrix farm you have to query IMetaFrameSession.SessionState. If the returned state of the session is MFSessionStateStale, no further attempt to read other session properties should be made. This state indicates that the session may no longer exist.
The following PowerShell script displays all active sessions within the farm and adds additional session information to the output. To check other session's states you only have to replace the session state type in the last line of the code.
#Type Definitions
$MetaFrameWinFarmObject = 1
$MFSessionStateUnknown = 0 #Unknown state
$MFSessionStateActive = 1 #User logged on
$MFSessionStateConnected = 2 #Connected to client
$MFSessionStateConnecting = 3 #Connecting to client
$MFSessionStateShadowing = 4 #Shadowing another session
$MFSessionStateDisconnected = 5 #Logged on but no client
$MFSessionStateIdle = 6 #Waiting for connection
$MFSessionStateListening = 7 #Listening for connection
$MFSessionStateResetting = 8 #Reset in progress
$MFSessionStateDown = 9 #Down due to error
$MFSessionStateInit = 10 #Initializing
$MFSessionStateStale = 11 #Stale session object
#Main
$farm = new-Object -com "MetaframeCOM.MetaframeFarm"
$farm.Initialize($MetaFrameWinFarmObject)
$farm.FarmName
$farm.Sessions | Where-Object { $_.SessionState -eq $MFSessionStateActive {color:black}}| Format-table Username,SessionName,AppName,ServerName,SessionState
Find disabled Application
Finding disabled applications is mostly useful in your production or test environment where you have to handle with many published applications. This property IMetaFrameApplication.EnableApp enables or disables the application.
- When you publish an application, it is enabled by default. Enabled applications are available to the users specified when the application was published. Disabled applications are not available to users.
- The application can become disabled internally if its server list becomes empty, or if its user list becomes empty and the application is not configured to accept anonymous connections.
- A disabled application is not available to clients.
#Type Definitions
$MetaFrameWinFarmObject = 1
#Main
$farm = new-Object -com "MetaFrameCOM.MetaframeFarm"
$farm.Initialize($MetaFrameWinFarmObject)
$farm.FarmName
$app = $farm.Applications
$app | foreach { $_ | ? { $_.EnableApp -eq 0 }}|Format-Table DistinguishedName
When you build a workflow using some of the PowerShell tasks you may come across a need for the special variable "$_". This variable represents the current pipeline object in PowerShell and is used in workflow tasks to refer to the passed in 'Input' object. One case where this comes up often is with the "Where-Object" task. When using this object your "Filter Script" property will typically contain something that looks like this:
$_.Status -eq "Running"
The above means to return all items from the Input object where the Status field is "Running"
I found this site that does a great job of explaining the special variables in PowerShell if you want to explore further:
http://www.computerperformance.co.uk/powershell/powershell_variables.htm
That site has a lot of tutorial pages on PowerShell covering the escape character I talked about in my previous post as well as a good summary of PowerShell syntax. I find myself on that site often from searching for PowerShell topics and often find answers there.
There was a question on the forums about calling the XenApp task Connect To Farm when using a domain user name. Since we are using PowerShell heavily under the covers the string passed in to this task for the username needs to use the PowerShell escape character whenever a reserved character for PowerShell is in the string. I searched Microsoft's site, but couldn't find much detail out there on this so I wanted to clarify here:
The escape character for PowerShell is the grave-accent character "`" (which on US keyboards should be in the upper-left of the keyboard to the left of the number 1.
I haven't been able to find much posted on reserved characters on Microsoft's site, but here is a good article that highlights what is in the PowerShell help documentation:
http://www.microsoft.com/technet/scriptcenter/resources/qanda/jan08/hey0117.mspx
Here is the list of characters from that article:
$
( )
*
+
.
[ ]
?
\
/
^
{ }
|
If you need to use any of those characters in a string then you will need to escape it with the ` character. For example, to pass in a domain username to Connect to Farm in XenApp then you will need to pass in "domain`/user" instead of just typing "domain/user".
In a previous post I covered how to integrate Wake On LAN into your workflow, but how many people are currently using Wake On LAN or at least know that the majority of their servers support it?