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
Creating Users and Managing Passwords in Microsoft Office 365
0 693 3In 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
How to clone a Windows Server 2012 or 2012 R2 Domain Controller
3 1569 3One of the coolest new features in Window Server 2012 and Windows Server 2012 R2 is the ability to clone a Domain Controller. In the past, if we had virtualized Domain Controllers and we actually took a snapshot of it and then rolled back to that snapshot, it would break the logon service on that … Continue reading How to clone a Windows Server 2012 or 2012 R2 Domain Controller
Detailed Forensic Investigation of Malware Infections – April 21, 2015
4 647 5How does an investigator hunt down and identify unknown malware? In this recording of our IT Security training webinar on April 21, 2015, Security expert Mike Danseglio (CISSP / CEH) performed several malware investigations on infected computers and identify symptoms, find root cause, and follow the leads to determine what’s happening. He demonstrated his preferred … Continue reading Detailed Forensic Investigation of Malware Infections – April 21, 2015
Pingback: How to make PowerShell the default console for Windows Server Core