In my new job, I get to work on a dedicated Citrix team again and I’m really enjoying it. I get the opportunity to work collaboratively with a group of experienced Citrix Admins/Engineers and also get the chance to do a lot of PowerShell. Recently, we had to run Helge Klein’s excellent Delprof2 against a set of servers because of space issues. After fixing the issue, I thought it would be a good chance to stretch my PowerShell skills and enhance a tool the team uses.
The original script runs fine, it just runs against the entire farm which in this case is over 700 servers. I wanted to create a script for our XenApp 6.5 environment and leverage Worker Groups to group our servers. I also wanted to try a graphical interface for the script.
PowerShell…GUI…what’s wrong with you?
I know, I know. Using a GUI with a PowerShell script is not typical, but I felt it was the best way to present a list of Worker Groups. Your Citrix environment may be smaller or not using that many worker groups, so displaying a list in the console may make more sense. I found this post which outlined how to do a list box in PowerShell.
First, I modified the dimensions of the parts of the list box so it would display all my worker groups.
Then, I populated the list box with worker groups using get-xaworkergroup
Finally, I display the List box and wait for the user to select a Worker Group and click OK or Cancel and stop the script.
If the user does pick a worker group and clicks OK, then we iterate through the servers in the Work Group and run delprof2.exe against them. This is where you could implement your own tool or procedure.
Here’s the list box:
Selecting a Worker group and clicking OK, will run delprof2.exe against all the servers in the WG.
You can get the script from Github.
Thanks for reading,