For all the power of PVS, managing a large environment can prove a troublesome and time-consuming task.

With multiple gold disks, dozens of application sets and different user silos with unique needs it’s not just a spin it up and forget it kind of thing. Proper automation provides the foundation that you need to:

– Deploy updated gold disks.
– Spin up and spin down capacity within a silo based on thresholds you determine
– Begin to treat your capacity as on demand rather than static silos

PVS comes with a PowerShell add-in that is not an easy beast to tame.

With the PowerShell SDK for other Citrix products such as XenDesktop and XenApp, the cmdlets used there will return PowerShell objects. These are easy to manipulate, query and modify. With the PVS PowerShell snap-in, this is not the case. Commands issue though the PVS PowerShell snap-in, MCliPSSnapin, do not return objects. Instead we are presented with large unsightly blocks of text. For example, if I was to run a query to get the details of a device in my farm, this is the kind of output that I can expect to get:

To add to this, if you are capturing details about multiple objects, the block of text just keeps growing and growing! The more objects you have, the more difficult it becomes to manage the output. So how can we take advantage of what could potentially be some very powerful automation functionality for our PVS environment?

The key is being able to predict what text will appear in the output and where it will appear. Let’s take the above command and output as an example. When issuing the command, we can return the output to a variable array. By knowing which line of the output will contain the piece of information that we need to extract will appear on, we are able to capture it. If I wanted the device ID field, I could do the following:

$result = Mcli-Get Device -p deviceName=device001
$lineInfo = $result[4]

I know that the 5 slot in the array will contain the line of text that corresponds to the device ID field. This leaves us with the entire line of text though so some additional manipulation is required.

$splitPosition = result.IndexOf(“:”);
$deviceID = $lineinfo.Substring($splitPosition + 2, $lineInfo.Length – ($splitPosition + 2));

I can locate the position of the colon with the string and then use that to split the string so that I only have the information to the right hand side of the delimiter.

As part of our Synergy Geek Speak Live! Session, we will be showing you how to use techniques like this to provide on demand capacity automation for your PVS environment using the PVS PowerShell in 9 easy steps:

  • Get the name of spare device in the source collection.
  • Get the details of that spare device.
  • Get the name of a device in the target collection.
  • Get the vDisk details of that device.
  • Delete the spare device from the source collection.
  • Add the spare device to the target collection.
  • Assign the vDisk to the spare device.
  • Add the device to AD group/delivery group.
  • Boot the device.

Be sure to join us at Synergy 2015 in Orlando for breakout session SYN514: Turn XenApp and XenDesktop into capacity on demand with Provisioning Services automation and learn about how your PVS infrastructure can shine!

Paul Stansel is an 18-year Citrix advocate who currently works as an architect focusing on EUC and Cloud solutions for a major insurance company. He has architected and implemented solutions for multiple Fortune 100 companies and has participated in the Citrix Customer Advisory Council. Paul speaks at various industry events and runs the popular blog Follow Paul on Twitter.

Shane O’Neill is a Senior Engineer for a major insurance company with responsibility for over 50,000 virtual users. Shane is a strong advocate of using automation where possible to streamline and enhance various processes related to Citrix products. He has experience with designing and deploying solutions for reporting, managing and optimizing XenDesktop, XenApp, PVS and VMWare using PowerShell and C#. You can follow Shane on Twitter.

Citrix invited the author of this blog post to present at Citrix Synergy 2015 and to participate in a related contest. The author received an entry into the contest for submitting this Blog.

Stay connected for all things Citrix Synergy – follow @Citrix on Twitter and join the conversation using #CitrixSynergy