Lock the VM Console when you close Hyper-V UI

There is a little feature that we snuck into Hyper-V recently that is very handy for our security minded users out there.  Normally, if you connect to a virtual machine with Remote Desktop or Enhanced Mode VM Connect, when you close the desktop you know that the next user to connect will have to provide user credentials.

However, if you are using basic mode VM Connect – then it is possible that the next user to connect will be able to jump straight in and use your credentials if you do not remember to manually log out of the virtual machine.  Luckily – this problem can now be avoided.  If you open up PowerShell and run:

set-vm "Windows 10 Enterprise" -LockOnDisconnect On

We will automatically lock the guest operating system session when you close VM Connect.