Citrix Machine Creation Services (MCS) is instrumental in generating machine catalogs derived from a single master image. To ensure the creation of unique machines, MCS undertakes an image preparation stage on a copy of the master image. By default, MCS performs several image preparation steps, including the activation of DHCP, Microsoft Office rearm, and Windows rearm. Within this stage, there’s an opportunity to incorporate additional custom scripts, either before or after the pre-existing image preparation steps.

In this blog post, we’ll delve into the types of supported scripts and provide guidance on how to seamlessly integrate them into the image preparation process. This customization not only enhances the operational efficiency but also improves the consistency and security of your image preparation workflow.

Adding image preparation steps

Custom scripts may be added at two points during the image preparation process: at the very beginning before all other steps or at the end after all steps except for Windows rearm. The following diagram shows the sequence of actions performed during image preparation with the default image preparation steps labeled in blue and the customization points labeled in yellow.

Image preparation supports custom scripts of any executable file format (.bat, .cmd, .exe, etc.). Note that PowerShell scripts will not work directly and should be called from a batch script instead. To add a step to the image prep process, the file path of the script must be added to “Before” or “After” on the following registry key, as shown in the screenshot below.

HK_LOCAL_MACHINE\Software\Citrix\MachineIdentityServiceAgent\ImagePreparation

An example showing the registry value that will cause c2.bat and c 3.cmd to be executed at the “After” stage in image preparation.

Multiple file paths may be added and will be executed sequentially in the order that they are listed. In the previous screenshot, c0.cmd and c1.cmd will be executed in that order before all other image prep steps, and c2.bat and c 3.cmd will be executed in that order just before Windows rearm. Each file path should be on a new line in the multi-string registry value, and spaces can be used in the file paths. If added to “Before”, the step will be performed before all other steps in image preparation. If added to “After”, the step will be performed after all steps except for Windows rearm.

Support for PowerShell scripts

PowerShell scripts may be used by calling them from a batch script like so:

Powershell.exe -ExecutionPolicy Bypass -File C:\scripts\pstest.ps1

Learn More

Incorporating custom scripts into your image preparation process is a powerful tool that administrators can use to elevate their MCS experience. As you customize your environment with these scripts, you’ll find many ways to improve how you manage your machine catalogs.  From optimizing efficiency to fortifying security, the benefits are without limit. We invite you to begin exploring these opportunities today, unlocking the full potential of your image preparation workflow. Don’t miss out on the chance to supercharge your MCS setup and take your image preparation to the next level! 

For additional information on the image preparation process, visit this blog post.