This assumes you have Windows Server 2022 Gen2 VM running on hyper-v that uses gen2 with UEFI and Secure Boot - it should work for win11 but i haven't tested that. This has only tested with a vanilla windows server 2022 VM so far (three times to write guide). I will comment this gist when i manage to move one of my domain controllers.
I suggest creating a fresh test windows VM and use this procedure on that test VM long before you try this on a production VM. And repeat after me 'i will backup all VMs with snapshots AND will backup with backup application before i do this`... ok...