Preventing and Correcting Image Cleanup Errors During Citrix Machine Creation Services (MCS)

by | Jun 26, 2017 | Infrastructure | 0 comments

Citrix Machine Creation Services (MCS) is a powerful tool used for image management to deploy desktops and servers for a XenDesktop and XenApp environment.

Here’s how it works: The MCS service automatically copies a master image read-only base disk that you have configured to the datastores and creates a number of virtual machines as linked clones that you specify. When you update a machine catalog, MCS copies a new base disk and reconfigures the virtual machines to use the new base disk. When all the machines have been updated, the MCS service automatically removes the old unused base disks.

However, if there are any issues that prevent the cleanup process from completing, you may be left with an orphaned MCS provisioning task, “DisusedImageCleanUp,” that never completes. Datastores becoming full, network connectivity issues, and power outages are common examples of issues that may interfere with the automated cleanup process. In this blog, we’ll explore ways to prevent and correct this from occurring.

Verifying an active task

Using PowerShell with the Citrix snap-ins from a Delivery controller, you can check for active tasks. When a catalog update is initiated, a DisusedImageCleanUp task will be created. This task will remain active and retry at 6-hour intervals.

  • Verify if any virtual machines are still waiting to be reconfigured for the new base disk. Enable the “Hosting/Pending Update” column from the Citrix Studio in the “Select Columns” action. Then check for the Pending Update= Yes, in the search panel.
  • This command will list any active tasks.

Get-ProvTask -Active $true

  • After all machines have been updated, the Pending Update for each machine should be “No.”
  • The DisusedImageCleanUp task will run at the next 6-hour retry internal and should delete the old base disk. Then the “Get-ProvTask -Active $true” command should not return any information.

Removing an orphaned DisusedImageCleanUp task

If all machines have been updated, you have verified that all old base disks are removed, and you still have an active DisusedImageCleanUp task, it may need to be removed manually.

Note: Follow your company’s backup procedures before you make any changes.

  • Run the following two commands to stop and remove the orphaned tasks.

Get-ProvTask | where {$_.Type -eq “DisusedImageCleanup” -and $_.Status -ne “Finished”} | Stop-ProvTask

Get-ProvTask | where {$_.Type -eq “DisusedImageCleanup” -and $_.WorkflowStatus -eq “Terminated”} | Remove-ProvTask

  • Run the “Get-ProvTask -Active $true” command to verify there are no longer any active tasks.

On rare occasions, this task may automatically be recreated.  In one case, we had an instance where there was a database outage during the cleanup process. There were some stale records in the database that had to be manually removed. To do so:

  • Back up your database before making any changes.
  • Open SQL Server Management Studio and expand your XenDesktop database. Right-click the table labeled “DesktopUpdateManagerSchema.PendingImageDeletes” and select “edit top 200 rows”.
  • Remove any stale records.

Note: There should just be the new row entry as shown below.

  • Run the commands to stop and remove the orphaned DisusedImageCleanup task.
  • Verify there are no longer any active tasks.

A clean Citrix Machine Creation Services environment can improve the efficiency of your VDI deployment. The steps above will help keep your Citrix MCS implementation healthy and reduce any perpetual pending tasks.

Need more information on Citrix Machine Creation Services or help removing errors? Email  We are happy to help.