dtoxic Posted December 25, 2019 Posted December 25, 2019 Here is a script for Powershell to set the pc to autologon one time [configurable] after restart, with a 15 sec delay Someone may find it handy Copy paste into Powershell ISE or txt and then rename to *.ps1 Tested on Windows 7 X64 Â $RegPath = "HKLM:\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Winlogon" $DefaultUsername = "Insert Username Here" $DefaultPassword = "Insert Password Here" Set-ItemProperty $RegPath "AutoAdminLogon" -Value "1" -type String Set-ItemProperty $RegPath "DefaultUsername" -Value "$DefaultUsername" -type String Set-ItemProperty $RegPath "DefaultPassword" -Value "$DefaultPassword" -type String Set-ItemProperty $RegPath "AutoLogonCount" -Value "1" -type DWord Start-Sleep -Seconds 15 ; Restart-Computer -Force Â
AC_Martin_J Posted February 20, 2020 Posted February 20, 2020 (edited) I appreciate you sharing the script, but please note that the password is stored unencrypted and visible to others in both the script itself (if you edit the code) and in the registry. You might want to consider using the Autologin-tool from Mark over at Windows SysInternals instead. It's a great tool to add autologin to kiosk-computers and such, while keeping the credentials safe since they will be encrypted. https://docs.microsoft.com/en-us/sysinternals/downloads/autologon To turn it back off, you simply run the tool again and disable the autologin feature.  In other situations, there's also a Cmdlet to gather credentials and store the password as a secure string which is handy. You can try the following to test it out: #Running this first line will open a prompt for you to enter username and password and store it in $Credentials $Credentials = Get-Credential #Running the second line will output the UserName that was entered previously, and in a readable formt $Credentials.UserName #Running the third line will output the Password as a secure-string (non readable) $Credentials.Password #You can then use the stored information when running the Invoke Cmdlet for example (ie running a scriptblock on another computer), or when connecting to Office 365. #Furthermore it's possible to convert the secure-string into an unreadable text format so you can save it in plain text but without the risk of having it compromised. #Running the fourth line will convert the password from a SecureString and store it in $Password $Password = $Credentials.Password | ConvertFrom-SecureString #You can then compare the output of $Credentials.Password and $Password by running them separately. The first one will show the SecureString-data, and the second will show the same information but in plain text while it can also be exported/saved for future use, unlike a securestring. #Running the fifth line will export the password in an unreadable plaintext-format and save it as a file, so you can import this at a later point in time (ideal when running scripts with the task scheduler where the script needs credentials in order to proceed). Set-Content "C:\temp\MyPasswordData.txt" $Password #Running the sixth line will import the password and convert it back to a securestring so you can use it in your scripts. $ImportedPassword = Get-Content "C:\temp\MyPasswordData.txt" | ConvertTo-SecureString  Hope this helps!   Edited February 20, 2020 by AC_Martin_J dtoxic 1
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now