Sometimes we just need a computer with the so-called auto-logon feature. This feature is without a doubt a security risk but on the other hand it is a good way to make computers as simple as possible for all users. Auto-Logon configruation is suitable for Kiosk mode or presentation computers where it should be as simple as possible. In this blog post I will provide a script to configure auto login without having to search the registry for the right keys. Let’s get started.
The Objective
In this part I will show you what happens if you run my script.

That’s it. Cool stuff. Which brings me to the code.
The Code
Before you run the code, check your PowerShell ExecutionPolicy settings. On Windows 10 computers the default setting is Restriced. In order to run the script, you have to change the policy to at least RemoteSigned.
Get-ExecutionPolicy Set-ExecutionPolicy RemoteSigned -Force

Ready ? Now it’s party time.
Copy the code below into PowerShell ISE or an editor of your choosing. Run the code and enter username and password. Then restart the computer and check if it works as expected.
### The code below configures Auto-Login on Windows computers ### <# Author: Patrick Gruenauer | Microsoft MVP on PowerShell Web: https://sid-500.com #> $Username = Read-Host 'Enter username for auto-logon (f.e. contoso\user1)' $Pass = Read-Host "Enter password for $Username" $RegistryPath = 'HKLM:\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Winlogon' Set-ItemProperty $RegistryPath 'AutoAdminLogon' -Value "1" -Type String Set-ItemProperty $RegistryPath 'DefaultUsername' -Value "$Username" -type String Set-ItemProperty $RegistryPath 'DefaultPassword' -Value "$Pass" -type String Write-Warning "Auto-Login for $username configured. Please restart computer." $restart = Read-Host 'Do you want to restart your computer now for testing auto-logon? (Y/N)' If ($restart -eq 'Y') { Restart-Computer -Force }
Fine, that’s it for today. See you next time with PowerShell.
Caution: To test this script in Hyper-V, you must disable Enhanced Session mode for the Hyper-V guest.
Categories: PowerShell, Windows 10
That is helpful. Would be great if you could do it remote without the need of sitting in front of the servers (i.e. data cener).
LikeLiked by 1 person
I don’t want to run this on my production machine… can I utilize a Sandbox instance to test it out without affecting my normal login process for the main operating system?
LikeLiked by 1 person
Sure, just use a VM.
LikeLike