Here is the painful way to convert a Citrix XenServer VM to work on Hyper-V (Hopefully without any BSOD’s!)

Firstly its a very good idea to snapshot your VM in the event that this goes wrong and you need to try again or another way. You can do this within the XenCentre application on Windows. Click on the VM and go to the Snapshots tab. Click on ‘Take Snapshot…’ and follow the prompts.

Once you have a snapshot, you need to uninstall the Citrix Management Agent. This is the equivalent of Vmware tools in a vSphere environment. You will find the package in appwiz.cpl (Uninstall a program). You should reboot once it has been uninstalled, this is to make sure that any locked files will have been removed. Make sure that the installation doesn’t start when the VM boots back up. You may have the Guest Tools in the virtual CD.

Now the management agent has been removed, we can move onto the Citrix devices. These are a pain to remove as they are presented as ghost devices. These need to be removed otherwise you will have a hard time booting the VM within Hyper-V. I found a useful script that automates some of this process, you can find it here: https://theorypc.ca/2017/06/28/remove-ghost-devices-natively-with-powershell/

Copy the PowerShell script from that webpage and save it as a .ps1 file on the VM you are migrating. This script will remove all ghost devices, you can run the file normally within a PS prompt:

PS> .\RemoveGhostDevices.ps1

This script will give you some feedback as to what it has removed. You should see quite a few devices have been removed!

Unfortunately, the management agent/tools uninstall doesn’t clean up after itself and some driver files may be left on the system. These would be left in C:\Windows\System32\drivers.

We can use the following PowerShell commands to check if there are any Xen files leftover:

PS> cd C:\Windows\System32\drivers\

PS> Get-ChildItem | ?{$_.Name -like “xen*”}

If there are any residual files, they will be printed to the console. To remove them, use this amended command:

PS> Get-ChildItem | ?{$_.Name -like “xen*”} | Remove-Item

You should now reboot the VM.

All the Citrix stuff should be removed from the VM at this point and you should be ready to export it. This can either be achieved by using a tool like Disk2vhd or using the export tool within Citrix XenCentre. You can export as an OVA and use 7Zip to extract the VHD out. This would then have to go into a Gen1 VM. Using Disk2vhd you are able to specify a VHDX format (Gen2 Compatible). I have had issues with booting when trying to convert the VHD from an OVA to a VHDX within Hyper-V. Your mileage may vary!

I hope this guide enabled you to convert a Citrix VM over to Hyper-V, its just a shame that the Citrix agent and hardware have such deep roots into the system.

Added note: You may have to mount your VHD/VHDX after exporting and make sure there are no xen driver files within \Windows\System32\drivers. These can sometimes be regenerated and placed back after the reboot at the end, if these driver files persist in that directory, you will most likely have trouble getting the VM stable within Hyper-V!

Categories: Expert Tutorial

0 Comments

Leave a Reply

Your email address will not be published. Required fields are marked *