How to AutoLogon Microsoft Windows using PowerShell

Home > Blogs > PowerShell > How to AutoLogon Microsoft Windows using PowerShell

How to AutoLogon Microsoft Windows using PowerShell

Like This Blog 4 Jason Helmick
Added by November 26, 2012

Do you ever just want Windows Server, or client for that matter, to automatically logon? This is a horrible idea in production and violates every security rule you can imagine. So don’t do this!  But…

I build a lot of test/dev environments and want my Servers to automatically logon and start PowerShell. In this blog I’ll show you the old-skool way of setting up auto logon for Windows. In the next blog, I’ll show you how to start PowerShell automatically on Windows Server Core rather than the old command prompt.

Remember I said old-skool? Yea, this comes from the old WinNT 4 days. You can setup AutoLogon in an old registry key “HKLM\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Winlogon”. PowerShell makes this a snap. You need to add the keys for Autologon, DefaultUserName and DefaultPassword. (Warning – the password will be stored in plain text in the registry)

PS C:\> New-ItemProperty -Path 'HKLM:\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Winlogon' -Name AutoAdminLogon -Value 1

PS C:\> New-ItemProperty -Path 'HKLM:\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Winlogon' -Name DefaultUserName -Value "Company\Administrator"

PS C:\> New-ItemProperty -Path 'HKLM:\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Winlogon' -Name DefaultPassword -Value P@ssw0rd

Of course, if you have several computers you need to auto logon you can use PowerShell Remoting. 

PS C:\> Invoke-Command -ComputerName S1, S2 -ScriptBlock {New-ItemProperty -Path 'HKLM:\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Winlogon' -Name AutoAdminLogon -Value 1}

PS C:\> Invoke-Command -ComputerName S1, S2 -ScriptBlock {New-ItemProperty -Path 'HKLM:\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Winlogon' -Name DefaultUserName -Value "Company\Administrator"}

PS C:\> Invoke-Command -ComputerName S1, S2 -ScriptBlock {New-ItemProperty -Path 'HKLM:\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Winlogon' -Name DefaultPassword -Value "P@ssw0rd"}

Now use your power wisely 😉

Knowledge is PowerShell

Jason Helmick
Director of PowerShell Technologies
Interface Technical Training

Videos You May Like

A Simple Introduction to Cisco CML2

0 3624 0

Mark Jacob, Cisco Instructor, presents an introduction to Cisco Modeling Labs 2.0 or CML2.0, an upgrade to Cisco’s VIRL Personal Edition. Mark demonstrates Terminal Emulator access to console, as well as console access from within the CML2.0 product. Hello, I’m Mark Jacob, a Cisco Instructor and Network Instructor at Interface Technical Training. I’ve been using … Continue reading A Simple Introduction to Cisco CML2

Configuring Windows Mobility Center and How to Turn it On and Off

1 1402 1

Video transcription Steve Fullmer: In our Windows training courses, we often share information about the Windows 8.1 Mobility Center. Mobility Center was introduced for mobile and laptop devices in Windows 7. It’s present and somewhat enhanced in Windows 8. Since we don’t have mobile devices in our classrooms, I decided to take a little bit … Continue reading Configuring Windows Mobility Center and How to Turn it On and Off

OSPF Adjacency Troubleshooting Solution – Getting Close to the OSPF adj

0 246 1

In this video, Cisco CCNA & CCNP instructor Mark Jacob shows how to troubleshoot OSPF Adjacency issues by showing the distance between routers with the show ip ospf neighbor command.

Write a Comment

See what people are saying...

  1. Pingback: How to make PowerShell the default console for Windows Server Core

Share your thoughts...

Please fill out the comment form below to post a reply.