Windows 10: Configure Auto-Logon with PowerShell Automation

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.


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

Tagged as: , ,

12 replies »

  1. Hi Patrick,

    I am trying to auto login to Citrix Files which has three steps.

    1. Auto Launch app
    2. Sign In using a company name
    3. Sign in with company credentials (which will be similar to my computer login)

    I got someone in Norway who has said that you can tweak the registry and it should work. If you go to this website below. But, I tried doing this and it does not work. So, I was wondering whether is there anyway this can be automated to run using a Powershell script or with the registry changes he has mentioned?



  2. 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?

    Liked by 1 person

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

This site uses Akismet to reduce spam. Learn how your comment data is processed.