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

Agile Methodology in Project Management

0 172 0

In this video, you will gain an understanding of Agile and Scrum Master Certification terminologies and concepts to help you make better decisions in your Project Management capabilities. Whether you’re a developer looking to obtain an Agile or Scrum Master Certification, or you’re a Project Manager/Product Owner who is attempting to get your product or … Continue reading Agile Methodology in Project Management

Creating Users and Managing Passwords in Microsoft Office 365

0 750 4

In this Office 365 training video, instructor Spike Xavier demonstrates how to create users and manage passwords in Office 365.   For instructor-led Office 365 training classes, see our course schedulle: Spike Xavier SharePoint Instructor – Interface Technical Training Phoenix, AZ 20347: Enabling and Managing Office 365    

IPv6 Port Redirection

0 391 0

In this video, Cisco CCNA and CompTIA Network + Instructor Mark Jacob demonstrates how to do port redirections in IPv6. If you have any questions or comments, please feel free to post them. Until next time. Mark Jacob Cisco and CompTIA Network + Instructor – Interface Technical Training Phoenix, AZ

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.