Citrix Blogs

Talking NITRO with PowerShell

As a Citrix Consultant and DevOps enthusiastic I’ve been promoting the use of automation scripts for Citrix XenDesktop and XenApp deployments for the last couple of years. Citrix has documented the use of unattended command line installers for the infrastructure components quite well and is providing more and more PowerShell script examples to make our DevOps life easier. A lot has improved since I spent many hours of reverse engineering those StoreFront 2.5 PowerShell modules to configure the required Store settings. Citrix has worked hard to not just improve the SDK itself to support all StoreFront MMC console settings and more, but they also provide better documentation for the PowerShell SDK, making it easier to build your own DevOps scripts.

In an age where end users are requesting faster delivery of applications and data, as they have grown accustomed to instant delivery of apps from public App Stores, IT departments have to put time and effort in automating infrastructure configurations. And as Citrix has adapted a much faster release cycle, it’s not just configurations, but deployments, upgrades and migrations of our Citrix infrastructure components that has increased the need for automated scripts as well. Without automating daily administration tasks, upgrade scenarios and stress tests it will be hard for IT departments to ensure service levels met and that superb user experience is delivered.

And as PowerShell gets more and more support from Citrix, I’ve been working hard these last two years to develop deployment and configuration scripts for the NetScaler appliances to make sure the entire Citrix stack is included in my DevOps toolkit. For me, the NetScaler still is that magical appliance that enables me to configure so much more that the Load Balancing and Gateway functionality I am using in my XenDesktop designs. So I’m eagerly extending my PowerShell NITRO Module with new functionality to support even more complex NetScaler deployment options as I learn to speak NITRO with my PowerShell scripts.

What is NITRO?

NITRO is the RESTful web service that runs on any NetScaler 9.2 or later and allows you to communicate with the NetScaler in a programmatic and more human readable way by making REST (REpresentational State Transfer) API calls. An architectural style based on simple HTTP requests and responses between the client and the server. REST is used to query or change the state of objects on the server side, which in my case is the NetScaler appliance.

To make a REST API call, you will need to provide the following information:

Even though that seems like a lot of information to provide, Citrix has made it easier for you as they have published the NITRO API reference, so you can simple navigate to the resource type you want to address and find all the information for the HTTP method, URL, Request Headers and Request Payload formatting that you need.

The PowerShell Module

Citrix does provide a NITRO API SDK for Java, C# and Python, that you can easily download from the appliance itself. But there is no PowerShell SDK. Luckily for me there was a blogpost series on Citrix Blogs in November 2014 that provided me with a PowerShell Module to get me started. And the past two years I’ve been extending the module with more functions to turn it into a more complete administrative module to not just add new configurations to the NetScaler, but be able to retrieve, update and delete configuration settings as well.

The PS-NITRO Module makes it easier to automate the configuration of your NetScaler as it provides you with simple functions that will transform the provided parameter information into the required JSON payload and URL to create that REST API request. You simple import the module, connect to the NetScaler and run the cmdlet that pushes the new configuration to NITRO. With this module enabling some basic NetScaler features can easily be scripted with just a few lines of code.

The Synergy presentation

Last year I introduced you to my module during a breakout session at Synergy as I showed you how to use it to configure a StoreFront Load Balancing configuration on the NetScaler.

I am honored to return to Synergy this year with a renewed breakout session, which will not just promote the module and its use, but will also give you more insights on how to build your own NetScaler automation scripts with PowerShell by using the built-in Invoke-RestMethod PowerShell cmdlet. And of course I want to personally invite you to extend the module with even more functions and configuration templates.

So, if you want to become a pro on NetScaler automation, I hereby invite you to join me on some NITRO scripting fun during my breakout session SYN325: Automating NetScaler: talking NITRO with PowerShell on May 24, 11:30 a.m. – 12:15 p.m in Orange County Convention Center, West Concourse, Level IV, W415D at Citrix Synergy.

Exit mobile version