Recently we had to clone a XenApp server, and needless to say there were issues when re-adding it to the farm. For reasons beyond this blog post, we had to basically remove all Citrix components from the new server, and reinstall everything, which went well.
Once the server was re-added to the farm we ensured that all updates/hotfixes installed and then there was the matter of adding the server to all currently published applications. Of course the Presentation Server/Delivery Console allows you to do this for each application, but not a way to do it in bulk. My hope was to be able to just add the server to every application in the farm since it was a clone, everything would be the same…this was nothing I could find a way to do with the installed Citrix consoles/tools.
I reviewed several other methods, workflow designer seemed overkill or what I wanted to accomplish, so I figured there would have to be a way that I could script this sort of thing, enter PowerShell.
Since PowerShell Cmdlets for XenApp is not installed by default, I needed to login to the Citrix site and download the version to fit my needs from here: http://community.citrix.com/display/xa/Download+SDKS. Of course they installed without a problem (I was using the x32 for XA 5on W2K3), and from there it was a simple matter of opening PowerShell and running Add-PSSnapin Citrix* and now I had access to all of the PowerShell Cmdlets for XenApp!
Not wanting to do anything without a simple test, I used Internet Explorer as my test application, running the following command to get the Application and pipe it into the command to add another server to it:
Get-XAApplication -BrowserName “Internet Explorer” | Add-XAApplicationServer -ServerNames <NEW SERVER NAME>
This of course added in my new server name to the list of servers hosting the application in XenApp. Tested and working. But that is just one application, what if we want to do it for one folder?
Get-XAApplication -FolderPath “Applications/Legacy Apps” | Add-XAApplicationServer -ServerNames <NEW SERVER NAME>
That was easy! Ok, let’s just get all of the published apps done with one shot:
Get-XAApplication | Add-XAApplicationServer -ServerNames <NEW SERVER NAME>
Note that these commands may take some time to run depending on the number of applications you have published. In our case, it was over a hundred, so it took a few minutes. As always we highly recommend testing and not just running these commands in a production environment. If you want to see what application(s) the above commands will run on, simply run the “Get-XAApplication …” part of the command (omitting the pipe “|” and everything after it). That will help you see what applications you are doing this on.
There are also a lot of other useful commands in the XenApp PowerShell Cmdlets, and if you are going to be doing anything on a bulk-scale, I highly recommend learning PowerShell and reviewing the documentation provided with the install to save a lot of time and frustration.
For more information or to view additional available commands provided with PowerShell for XenApp, look at the help file installed with the PowerShell Cmdlets (depending on your version/install location): <drive>:Program FilesCitrixXenApp CommandsenCitrix.XenApp.Commands.chm or <drive>:Program FilesCitrixXenApp Server SDKCitrix.XenApp.Commands.chm
As always, feel free to contact us at Intrinium for any more information!