• How to Automate Enabling PVS-Accelerator on Citrix Provisioning Target Devices

    December 10, 2020

    PowerShell, PVS, XenServer

    Recently, in one of the Slack Workspaces I am part of, someone asked how to enable PVS-Accelerator on numerous Citrix Provisioning (PVS) target devices. I wrote this article to explain how I came up with a Proof of Concept (PoC) script.

    “Is there any way to enable PVS Accelerator on all target devices in a large collection? So far, I find no script or PowerShell to do this.”

    I had a little bit a time between conference calls, so I thought this would be an easy problem to solve. Five hours later, I figured it out and had a working PoC script.

    I asked for information on the PVS, target device VDA, target device Windows, and hypervisor versions. I then built a matching environment as best I could.

    To understand what PVS-Accelerator is, its requirements, and how it works, please read this from the product documentation.

    Since this is not an article on installing, configuring, and using PVS-Accelerator, here are the items I completed in my lab.

    1. Installed and configured PVS 1912 LTSR CU2
    2. Installed and configured PVS-Accelerator in my Citrix Hypervisor (XenServer) 8.2 pool
    3. Installed a CVAD 1912 LTSR CU2 Delivery Controller
    4. Built a Windows 10 VM and installed the CVAD 1912 LTSR CU2 VDA
    5. Captured the Windows 10 VM into PVS
    6. Created a template of the VM
    7. Used the Citrix Virtual Desktops Setup Wizard (VDSW) to create three target devices

    I noticed that my three target devices had PVS-Accelerator disabled, as shown in Figure 1.

    Figure 1
    Figure 1

    I found out I had a typo between the Site name between PVS and what I entered when configuring the PVS-Accelerator in XenServer. Once I had that typo corrected, I used the VDSW to create a fourth target device. That target device has PVS-Accelerator enabled, as shown in Figure 2.

    Figure 2
    Figure 2

    Now I was faced with the same issue as the person who asked the question; How do I automate enabling PVS-Accelerator on the other three target devices?

    Time to head to the Citrix developer documentation and search the Citrix Provisioning Services PowerShell page. I changed the Versions, Figure 3, to 1912.

    Figure 3
    Figure 3

    As shown in Figure 4, I searched for “Accelerator”, which seemed obvious to me.

    Figure 4
    Figure 4

    I guess that isn’t as obvious as I thought it would be. I do not see search results for setting PVS-Accelerator for a device.

    I can see in Figures 5 and 6 the PVS-Accelerator Enabled option on one of the first three devices and the fourth device.

    Figure 5
    Figure 5
    Figure 6
    Figure 6

    OK, this “PVS-Accelerator Enabled” property must exist in the device.

    After running Get-PVSDevice -Name BaseName004, I get what you see in Figure 7.

    Figure 7
    Figure 7

    I don’t see a property that has “pvs” or “accelerator” in its name. Maybe it is the other device cmdlet, Get-PvsDeviceInfo, as shown in Figure 8.

    Figure 8
    Figure 8

    Nope, nothing there either.

    Finding this information is getting frustrating. Looking back at the PVS-Accelerator documentation, in the section How does PVS-Accelerator work, it stated, “PVS-Accelerator employs a Proxy mechanism that resides in the Control Domain (dom0) of Citrix Hypervisor”. OK, how about looking for the word “proxy”. In the results from Get-PvsDevice and Get-PvsDeviceInfo, the only property with “proxy” in the name is XsPvsProxyUuid.

    I know I want to set a value for a property for a device. How about looking in the help text for Set-PvsDevice. I did a Get-Help Set-PvsDevice -Full, and then a Find for “proxy”, as shown in Figure 9.

    Figure 9
    Figure 9

    Maybe this “EnableXsProxy” is what I need? Searching for “EnableXsProxy” yields the result shown in Figure 10.

    Figure 10
    Figure 10

    Maybe the parameter “-EnableXsProxy” is what I need.

    I will try it on the target device, BaseName001.

    Figures 2 and 5 show the “Before”.

    Figure 11 shows running the Set-PvsDevice cmdlet.

    Note: I used -PassThru to get the PVS Device object returned.

    Figure 11
    Figure 11

    There was no error returned from running the cmdlet, but I do not see either an XsProxy or EnableXsProxy property.

    What do the PVS Console and XenCenter show? Figures 12 and 13 show that the option PVS-Accelerator Enabled is now enabled.

    Figure 12
    Figure 12
    Figure 13
    Figure 13

    For the target device BaseName001, the PVS-Accelerator status shows as Stopped because it is off. After powering on the device from the PVS Console, the status changes, as shown in Figure 14.

    Figure 14
    Figure 14

    For BaseName002, I will try the example from the help text:

    EXAMPLE 1: Set PvsDevice for Individual Fields
    
    $o = Get-PvsDevice -Name theDevice -Fields LocalWriteCacheDiskSize
    
    $o.LocalWriteCacheDiskSize = 1024
    
    Set-PvsDevice $o
    
    Get the PvsDevice into a $o variable. Change the $o field values and then Set the PvsDevice with the result.
    
    The -Fields parameter with only the needed fields specified makes the Get work faster because only those fields are retrieved.
    
    
    

    Figure 15 shows the results of running: $o = Get-PvsDevice -Name “BaseName002” -Fields EnableXsProxy.

    Figure 15
    Figure 15

    OOPS! It looks like the EnableXsProxy property is not stored with the device. It would be nice to know where this property is stored. Using the PowerShell cmdlets, there is no way to retrieve the setting for PVS-Accelerator Enabled.

    It appears that using Set-PvsDevice is the only way to process multiple target devices.

    Here is the PoC script I came up with to automate enabling PVS-Accelerator for all target devices in a collection.

    Import-Module "C:\Program Files\Citrix\Provisioning Services Console\Citrix.PVS.SnapIn.dll"
    $Devices = Get-PvsDevice -CollectionName <CollectionName> -siteName <SiteName>
    ForEach($Device in $Devices)
    {
        Write-Host "Processing target device $($Device.name)"
        $DevGuid = $Device.Guid.Guid
        $null = Set-PvsDevice -EnableXsProxy 1 -Guid $DevGuid
    }
    

    The first thing I did was to manually disable PVS-Acceleration for all the target devices, as shown in Figure 16.

    Figure 16
    Figure 16

    Figure 17 shows the script running.

    Figure 17
    Figure 17

    With all four target devices powered on, Figure 18 shows the PVS-Accelerator status.

    Figure 18
    Figure 18

    Now that I enabled PVS-Acceleration for all the target devices, I have more questions than answers.

    1. Why was this so hard to figure out?
    2. Why does the property name have nothing obvious to do with PVS-Accelerator?
    3. Why is the EnableXsProxy property not stored with the device?
    4. Why is there no way to determine the status of PVS-Accelerator for a target device outside of using XenCenter or the PVS Console and manually checking each target device?

    I learned four lessons from creating this PoC script.

    1. Since the state of PVS-Accelerator is unknown and undeterminable for a target device, there is no way to know the state and skip target devices with the state enabled. For a device collection that contains hundreds or thousands of devices, you must process every device, whether needed or not.
    2. In my testing, using Measure-Command, it takes between 500 and 600 milliseconds to process a device with the Default setting of EnableXsProxy of “” and 6 milliseconds to process one with EnableXsProxy set to 1.
    3. There is no return status given, so there is no way to know if attempting to set EnableXsProxy to 1 succeeded or failed.
    4. Since the state of PVS-Accelerator is unknown and undeterminable, there is no way to filter only those devices that need the state changed.

    If this were a script I would release to the community, here are some changes I would make.

    • Add full help text
    • Add parameters for the PVS Site and Device Collection
    • Verify the data entered for the parameters
    • Use an environment variable for “C:\Program Files” when importing the PVS module

    I always create a transaction log file that shows what the script did with the computers processed, but that would not be possible with this script because of the four lessons listed above.







    About Carl Webster

    Carl Webster is an independent consultant specializing in Citrix, Active Directory, and technical documentation. Carl (aka “Webster”) serves the broader Citrix community by writing articles (see CarlWebster.com) and by being the most active person in the Citrix Zone on Experts Exchange. Webster has a long history in the IT industry beginning with mainframes in 1977, PCs and application development in 1986, and network engineering in 2001. He has worked with Citrix products since 1990 with the premiere of their first product – the MULTIUSER OS/2.

    View all posts by Carl Webster

    No comments yet.

    Leave a Reply