A virtual desktop pool is a group of identically configured virtual machines on a Remote Desktop Virtualization Host (RD Virtualization Host) server. All virtual machines in a virtual desktop pool are identically configured; a user should see the same virtual desktop regardless of which virtual machine in the virtual desktop pool the user connects to.
Therefore, when you’re setting up a VDI system, you often want the virtual machines in a pool to be “stateless images,” so that when the user logs off, the virtual machine is reset to a known state. There’s an easy way to do this with Windows Server 2008 R2.
First, prepare your virtual machine in the initial state you want. Log off once you have finished your preparations.
Second, create a Hyper-V snapshot of the virtual machine.
Finally, rename the snapshot so that it contains “RDV_Rollback” (without the quotes) anywhere in the name.
That’s it. Now, as soon as the user logs off, the virtual machine will automatically roll back to this snapshot, reverting all changes made by the user.
Some things to keep in mind:
- This feature is only applicable to virtual machines in a virtual desktop pool, not personal virtual desktops.
- The RDV_Rollback marker must be on the most recent snapshot.
- The rollback is only done if the user connected through the Connection Broker. If you connect directly, then log off, no rollback will happen. (This allows you to make further changes and take a new snapshot.)
- The rollback will not happen if there is anyone logged onto the virtual machine (even if they’re disconnected).
If there is a problem when Remote Desktop tries to apply the snapshot, a message will be logged to the Debug log of the TerminalServices-TSV-VmHostAgent eventlog: “Failed to request Hyper-V to apply a snapshot. Verify Hyper-V status. VM=<vmName>, Hr=<errorCode>”.
If you see this error, make sure that you haven’t modified Hyper-V’s Role-based Access Control to remove the permissions for “TS VM Host Agent.”