Hyper-V: lock the console of the VM at closing [Quick Guide]

6:10 pm November 21, 20167114

I. introduction

logo-hyperv5 new version of Hyper-V into Windows Server 2016 contains a feature that allows to automatically lock the session on the BONE when you close the console VM, open from Hyper-V Manager.

When this option is enabled, this will ensure that you leave a console with a session open and unlocked, you never know…

There is no option directly in the Hyper-V Manager to set this up, nor in the settings of the VM. So, we’re going to have used PowerShell to perform this configuration.

II. configure the LockOnDisconnect option

open a PowerShell console, then type the following command, substituting the name of the VM by VM you want to target.

 Set - VM "ADDS-01" - LockOnDisconnect On 

otherwise, you can also activate this option on all virtual machines via a single command:

 Get - VM | Set - VM - LockOnDisconnect On 

for those who would like to if sure that setting is passed, you can list your VMs and the value of this option for each VM with the following command:

 PS C:UsersAdministrateur > Get - VM | Name, LockOnDisconnect Name LockOnDisconnect - ft-ADDS-01 On WDS - 01 On LEADER-01 On 

if it does not, it would seem that it is necessary to restart your hypervisor for changes are applied (or perhaps only the VM?). Here, this tutorial is already done but I think that this trick will serve you well! 🙂