JuggeroniPizza
JuggeroniPizza

Reputation: 33

Automatically logon after restart

So I was wondering if this is possible. I am somewhat new to Powershell scripting and have pretty much made a script for every process in our setups and am looking to put them together to make them more automated. Right now I am looking to see if it would be possible to automatically sign in with a provided password (would use securestring and not a stored password) to a domain user account that was different than what was last signed in. If this is possible could you point me in the right direction, then I understand. Thanks!

Upvotes: 3

Views: 5010

Answers (1)

codewario
codewario

Reputation: 21418

Check out this script from the Technet Gallery, Set-AutoLogon.ps1. Before you initiate the reboot, you'll want to set the login information for the user who should be logged into the workstation on the next boot. Do note that this will store your username and password in plaintext within the registry. This is not a shortcoming of the script, but is just how the functionality works within Windows.

The script works by setting three registry key properties to specific values (4 technically, but in your case you probably don't want to change the default number of logins from 1):


If you were doing this manually without Set-AutoLogon.ps1, under HKLM:\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Winlogon, set (or create if missing) the following properties:

  • AutoAdminLogon: 1 (String)
  • DefaultUsername: targetUserName (String)
  • DefaultPassword: targetPassword (String)
  • AutoLogonCount: 1 (DWORD)

Like I said, note that the password is stored there in plaintext. That said, with each automatic logon (so each time the computer reboots), AutoLogonCount will decrement by 1. For example, if you set this to 5 it will count down from 5. Once this property reaches zero, AutoLogonCount and DefaultPassword are wiped from the registry and AutoAdminLogon is set back to 0.

Upvotes: 5

Related Questions