Hello Tim, I am Henry and I want to share my insight about your issue
The behavior you're seeing is by design. When you run ExportSystemDefinition with CopyVmStorage = false, Hyper-V intentionally places a temporary lock on the VM's disk chain. This is done to guarantee the consistency of the exported configuration and its associated checkpoints. This lock, however, is what prevents the live merge process from running.
My recommendation to handle this without restarting the VM or the service is to isolate the lock to a temporary checkpoint that you create and then immediately delete.
- Create a Temporary Checkpoint: Before running your export script, create a new checkpoint for the VM. Let's call it "TempExportCheckpoint".
- PowerShell:
Checkpoint-VM -Name "MyVM" -SnapshotName "TempExportCheckpoint"
- PowerShell:
- Run Your Export Script: Execute your existing C# code as-is. The export will now reference the state of the VM at the moment "TempExportCheckpoint" was created. The persistent lock is placed on the chain including this new checkpoint.
- Delete the Temporary Checkpoint: Immediately after the export is complete, delete the "TempExportCheckpoint".
- PowerShell:
Remove-VMSnapshot -VMName "MyVM" -Name "TempExportCheckpoint"
- PowerShell:
Because the export's lock was tied to the temporary checkpoint you just deleted, the lock is cleanly released from the running VM. Any other checkpoint deletions you perform after this will trigger their live merges correctly without any delay.
I hope this information is helpful.