Script Based Actions was mentioned in my ControlUp 3.0 overview blog as one of the new major additions in ControlUp 3.0, this blog post will provide an in depth coverage on the new SBA feature.

SBA’s allows ControlUp admins to extend the built-in management actions library by importing PowerShell, VB or batch scripts into the console. This powerful feature enables admins to quickly select the relevant targets, execute the script and monitor the execution status via the script results screen. In addition to creating your own actions, the community SBA library offers a wide selection of existing SBA’s that were uploaded by ControlUp community members and the Smart-X expert team.

I figured it would be best to cover this feature via 2 use cases:

  • Create and execute an internal organization SBA
  • Install SBAs from the community actions library

Creating and executing an internal organization SBA – “Create XenApp Published Desktop”

In this example we will create a new SBA called “Create XenApp Published Desktop”, this SBA will allow us to quickly create a Published Desktop for new XenApp 6.5 servers in our farm. This example will utilize some of the advanced SBA features like security context and script arguments.

To create a new SBA, we need to click on the Script-Based Actions button (located on the Home ribbon bar), switch to the Organizational Actions tab and click on the ‘New’ button. Now let’s start configuring the new SBA, the first wizard screen is where we set the SBA name and configure some important properties:

Most fields are self-explanatory but let’s review some of the advanced fields:

  • Assigned to – this is the type of ControlUp object that the SBA will act upon. The possible options include Computer, Session, Process or Advanced. This SBA will create a published desktop for each XenApp server so I choose the Computer object only. The Advanced option permits your action to be invoked from multiple contexts (consider a computer action that can be invoked when selecting an entire folder of computers).
  • Execution Context – this is where the script is actually executed. The possible options include Target Computer, ControlUp Console or Other Computer. In my case, I want to run the PowerShell code on each selected XenApp server so I choose the ‘Target Computer’ context. The “Other Computer” option allows you to select an executing computer when you run the SBA. This option accommodates advanced scenarios, such as when the script won’t run without a specific software package which does not exist on your target computers (like the XenDesktop PowerShell modules).
  • Security Context – this option configures the user account that will be used to execute the SBA script. You can choose the agent Local System account (assuming the execution context is not the ControlUp console) or prompt for AD account credentials during runtime. I need to run the PowerShell code with Citrix XenApp admin credentials so I choose the ‘Prompt upon execution’ option.

Let’s click on Next in order to configure the actual script:

The most important field here is the ‘Script Type’. ControlUp supports Batch, VB and PowerShell scripts, in this example I obviously choose the PowerShell option. This is the actual PowerShell script:

Add-PsSnapin Citrix.XenApp.Commands
$appname = $args[0]+" Desktop"
New-XAApplication -ApplicationType ServerDesktop -DisplayName $appname -FolderPath "Applications" -Description "Admin Desktop for Remote Administration" -WindowType "99%" -ColorDepth Colors32Bit -Accounts "Controlup\domain admins" -Servernames $args[0

This is a simple PoSH script that will load the XenApp PowerShell snap in and create a new published desktop for the selected XenApp server. Please note we are using “$args[0]” as a substitute for the XenApp server name both in the published application name and the published application servers list. ControlUp makes this possible by supporting script arguments, which we’ll configure at this point:

For this specific script I choose the ‘Name’ attribute which is actually the managed ControlUp computer name as it appears in the Computers view. We can choose any computer attribute that appears in ControlUp’s information grid, which allows us to pass real-time data as arguments to the SBA during runtime.

After clicking on Finish, the new SBA will appear in ‘My Draft Actions’ tab:

By design, a draft SBA has 2 limitations:

  • A draft is seen and can be executed only by the ControlUp user who created it.
  • A draft can only be executed on a single target at a time.

The draft mode is designed for testing and validating your newly created SBA. Once you are certain the script works as expected, you can click on Finalize in order to expose the SBA to all ControlUp admins in your organization and allow execution on multiple computers.

Now that the new SBA is ready, let’s execute it on a couple of XenApp servers and see the results in the XenApp AppCenter console. The first step would be selecting the XenApp servers and launching the new ‘Create XenApp Published Desktop’ SBA:

I selected 4 servers (CUXEN65TS02 through 05) and clicked on “Create XenApp Published Desktop”, which is now available on the Script Based Actions menu. The next screen in this example would be the select credentials screen (since we configured the script to prompt the user for credentials when the script is invoked):

I selected XenApp admin credentials (which I have previously saved for reuse in ControlUp) and clicked OK to launch the script. The next screen is the SBA results screen, here we can see the script status in real-time, the output, exit code and any relevant errors. Here is the results screen for this SBA launch:

As we can see the SBA completed successfully on all 4 XenApp servers. We have 4 different results groups because the published application properties are different for each server (published app name and server list). Now it’s time to visit AppCenter and make sure the new published desktops are visible (don’t forget to run discovery…):

That’s it! Now we have a quick and simple way to create published desktops for any XenApp server in our farm. This is obviously a simple example but the same method shown here can be used to create and execute any PowerShell action on multiple targets easily and efficiently

Install SBAs from the community actions library

The SBA community actions is an ever growing library of actions that are created and shared by ControlUp admins and the Smart-X expert team. In order to review the existing list of community actions simply click on the Script-Based Actions button:

We already have more than 20 community actions including cool ones like ‘IE: URLs” which will list the URLs associated with a specific IE process (excellent for figuring out which site is causing performance issues) and useful ones like ‘Change XenApp Logon Mode’ or ‘Enable XenDesktop Maintenance Mode’.

In order to add a community action simply click on the green Add button:

Once the community action is installed it will appear in the Organizational Actions tab and cab be executed by any authorized ControlUp admin. You can use the ControlUp Security Policy feature to delegate specific SBAs based on AD groups and users.

For additional reading and more details on the various SBA options, please refer to the SBA online documentation. A full list of Community SBAs can be found here.

I hope you appreciate the limitless possibilities the new Script Based Actions feature has enabled for ControlUp. We will keep adding new community SBAs based on customer feedback and we plan to post specific blogs on some of them so stay tuned.

That’s it for now, see you in the next ControlUp 3.0 deep dive blog

Yoni Avital

Subscribe to Our Blog

Get tricks and tips to do your job better and the latest news about ControlUp product releases.