Skip to main content
3 of 3
added 375 characters in body
YorSubs
  • 959
  • 1
  • 15
  • 34

PowerShell, Windows 10 autologon inside a Hyper-V VM

I have a pristine Windows 10 VM inside a newly installed Hyper-V on a newly setup Windows 10 host, and have been trying to get the VM to autologon using PowerShell. I've spent quite a few hours on this, over 3 weeks, going through dozens of pages, and nothing works. I simply canno find anything that will cause the VM to autologon after reboots (after the below, I end up with the logon screen and have to manually enter the password). Please can someone show me how to get this VM to autologon?

Edit: An Admin seems to have closed my question, citing: This question already has answers here: Change user for automatic login (2 answers) How do I change automatic logon via Script or Command Line? (3 answers) But that is not true, and my question is explicitly different from those questions for a very specific situation that is not covered in those questions relating to Hyper-V (as stated in both the question and the question title). Those linked articles do not answer this scenario at all.

$username = "User1"
$password = "password"

# Set registry keys for auto logon
New-ItemProperty -Path "HKLM:\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Winlogon" -Name "AutoAdminLogon" -Value "1" -PropertyType String -Force
New-ItemProperty -Path "HKLM:\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Winlogon" -Name "DefaultUserName" -Value $username -PropertyType String -Force
New-ItemProperty -Path "HKLM:\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Winlogon" -Name "DefaultPassword" -Value $password -PropertyType String -Force
New-ItemProperty -Path "HKLM:\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Winlogon" -Name "ForceAutoLogon" -Value "1" -PropertyType String -Force

Edit: I have finally found a solution for this; it has to do with "Enhanced Mode" on Hyper-V. I will create an answer below with the details and hopefully this is of use to others.

YorSubs
  • 959
  • 1
  • 15
  • 34