A little over a year ago, I created a utility to make managing Citrix App Layering User Layer Repair files easier for customers. The User Layer Repair Utility supported automation for copying selected repair files to selected User Layer folders. You can find the original blog post here.

Then, last September, I added the ability to expand the size of selected user layers, which is hard to do with the product alone. I covered this functionality in this blog post on expanding user layers.

Recently, I have been working on the ability to compress user layers. Several customers asked if I could also add the ability to reset user layers to make it easier for the help desk to do that when needed.

I have spent a while on updates that include these changes, plus the ability to use the expand, compress, and reset options on Full User Layers as well as User Personalization Layers and FSLogix Profile and Office containers. Given all this new functionality, I renamed the utility the User Layer Management Utility because it is now about much more than just copying repair files.

User Layer Management Utility

The tabs available in the utility are Reset, Repair, Expand, and Compress. Repair can only be used with normal Full User Layers while the rest can also be used with the User Personalization Layers or FSLogix containers.

  • Reset: Used to rename a user layer. This means the user creates a new user layer the next time they log on. The old layer is renamed, not deleted. See the Reset section below for more details.
  • Repair: Used to copy selected application repair files to selected user layer folders. This can only be used with the full Citrix App Layering User Layer. Repair files are used to clean out files and registry settings from the user layer. See the original blog post for a detailed explanation.
  • Expand: User layers, User Personalization Layers. and FSLogix containers are all based on mounting VHD or VHDX files that are created with a defined size. Sometimes you have to increase the size of the VHD/VHDX file. Both App Layering and FSLogix provide the ability to do that for all users via GPO or registry change, but not for a subset of users. Here you can selectively choose which VHDs to expand, and the scripting will use diskpart to expand the size of the VHD/VHDX file.
  • Compress: VHD files are normally created thin provisioned, and they grow as more space is used within the file. However, if many files are deleted, the space is not reclaimed. Also, because NTFS prefers free blocks to deleted blocks, the file will keep increasing in size even if there are deleted blocks that could be used. This Compress function will use diskpart to compress the VHD/VHDX file to remove deleted blocks.

In the OS Layers drop down, User Personalization Layer, FSLogix Profile, and FSLogix ODFC have been added as choices because these are not considered OS layers. When any of these are selected, all the VHD/VHDX files in the defined share paths on the setup tab are retrieved. Also, the design has been changed so that user layers and app layers are retrieved separately from the OS layer selection and are stored locally for each OS layer. This makes working with the utility and filtering the lists much faster. Filtering allows entering wildcard searches. If “ez” is entered its like entering “*ez*”. Pressing enter after adding a filter will perform the filtering access, as will clicking the arrow. On the repair tab, where there are two filter boxes, pressing enter will include both filters. The date/time of the last time the User Layers were obtained is listed in the table header. This is specific to each OS layer or the UPL, Profile, or ODFC Layers/containers.

Another new feature is a Running Log on the right side of the utility that shows status messages for the length of the session. Most of the messages have been moved to the log area, which always shows the newest entries at the top.

Lastly, for the interface, Help has been fully updated.

Now, let’s look at the new functionality in more detail.

Reset

Use the Reset tab to rename selected user.

Reset is used to give users a new user layer or FSLogix container. Reset will rename the old VHD/VHDX using a format of vhdname-REN-DateTime.vhd (for example, rzylowski.vhd-REN-5-23-2021-13-51-50.vhd).

To use the Reset feature:

  1. Click Get OS Layers to get a list of OS layers from the appliance.
  2. Select an OS layer. This will load the OS layer’s LayerId.
  3. Click on Get User Layers to get a list of user layers or FSLogix containers.
  4. Select the desired VHD/VHDX files to reset
  5. Click “Rename Sel User Layers”. This will rename any selected layers if they aren’t in use.
  6. It is also possible to restore a previously reset user layer by checking it, then clicking on the “Restore Sel User Layers”. This will also rename the existing User Layer, if there is one, as if it were being reset.

Please note, the search boxes can be used to perform a wildcard search. For example, to find only renamed user layers, type “ren” into the User Layer search and press the arrow or enter. When using search, you must perform the action while the search is defined. You cannot do multiple searches selecting different layers as you go.

Deleting user layers is not an included function of the utility and must be handled separately.

Compress

The other new feature in this version is Compress, which is used to remove deleted blocks from a VHD/VHDX to shrink the size used within storage.

To use the Compress feature:

  1. Select an OS layer. This will load the OS layer’s LayerId. You can also select UPL, or either type of FSLogix layer.
  2. Select the desired user layers/FSLogix containers. If necessary, run the “Get User Layers” first.
  3. Click the “Get User Layer Size” to attach the layer and get the current size in MB.
  4. Click “Compress Sel User Layers” to compress the VHD/VHDX files.

The results of the Compress operation will be added to the table, as seen above.

The utility uses PowerShell to run diskpart scripts for compressing just like it does for expanding. The compact vdisk operation removes the space used by deleted files. The PowerShell for this looks like the following:

We are first selecting the vdisk, then attaching it to the console machine read only, compacting it, then detaching it. Then the script runs a similar command to get the new size and update the table with the new size so you know whether it worked.

There is also a script that will compress all defined user layers that can be run within a scheduled task or on demand using the “Compress All User Layers” button. This will look for any VHD/VHDX files in any of the defined shares in the setup section and try to compress them. If you do run this as a scheduled task, it should be run with the highest privilege and must be configured to run as a user that has access to read and write for all of the defined shares.

For any of the Reset, Expand, or Compress scripts, if the VHD/VHDX is in use, they will error out and no harm will be done. Deletion and/or removal of the renamed layers is not currently part of the utility.

Setup

The important fields for these new functions in Setup are those listed in section D. The User Layer Share entry can be used for either Full User Layers or User Personalization Layers. The FSLogix entries can be used or left blank, depending on your needs. If you are only using FSLogix, leave A, B, C, and the User Layer Share empty.

I hope you find the utility useful.

Don’t Forget!

This is new functionality added to the utility that has not been tested outside of a lab environment. Please start by using this in a non-production setup. Treat it like any script you would develop yourself and test it well before adding it to your production environment.

Remember this is to be used at your own discretion and is not supported by Citrix. You can download the utility at the bottom of the original blog post and report any issues in the comments.


This software application is provided to you “as is” with no representations, warranties or conditions of any kind. You may use and distribute it at your own risk. CITRIX DISCLAIMS ALL WARRANTIES WHATSOEVER, EXPRESS, IMPLIED, WRITTEN, ORAL OR STATUTORY, INCLUDING WITHOUT LIMITATION WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, TITLE AND NONINFRINGEMENT. Without limiting the generality of the foregoing, you acknowledge and agree that (a) the software application may exhibit errors, design flaws or other problems, possibly resulting in loss of data or damage to property; (b) it may not be possible to make the software application fully functional; and (c) Citrix may, without notice or liability to you, cease to make available the current version and/or any future versions of the software application. In no event should the code be used to support of ultra-hazardous activities, including but not limited to life support or blasting activities. NEITHER CITRIX NOR ITS AFFILIATES OR AGENTS WILL BE LIABLE, UNDER BREACH OF CONTRACT OR ANY OTHER THEORY OF LIABILITY, FOR ANY DAMAGES WHATSOEVER ARISING FROM USE OF THE SOFTWARE APPLICATION, INCLUDING WITHOUT LIMITATION DIRECT, SPECIAL, INCIDENTAL, PUNITIVE, CONSEQUENTIAL OR OTHER DAMAGES, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. You agree to indemnify and defend Citrix against any and all claims arising from your use, modification or distribution of the code.