How to AutoLogon Microsoft Windows using PowerShell
How to AutoLogon Microsoft Windows using PowerShell
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
You May Also Like
AutoAdminLogon, AutoLogon, Invoke-Command, New-ItemProperty, Windows PowerShell
Agile Methodology in Project Management
0 184 0In 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
An Overview of Office 365 – Administration Portal and Admin Center
0 943 3This is part 1 of our 5-part Office 365 free training course. In this Office 365 training video, instructor Spike Xavier introduces some of the most popular services found in Microsoft Office 365 including the Admin Portal and Admin Center. For instructor-led Office 365 training classes, see our course schedule: Spike Xavier SharePoint Instructor – … Continue reading An Overview of Office 365 – Administration Portal and Admin Center
Creating Users and Managing Passwords in Microsoft Office 365
0 786 4In 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
Pingback: How to make PowerShell the default console for Windows Server Core