Jump to content

Autologon One time and Restart


Recommended Posts

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

 

Link to post
Share on other sites
  • 1 month later...

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 by AC_Martin_J
Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

  • Similar Content

    • By Canadian Dental Services
      Hi all,
      I recently did a clean upgrade to Windows 10 on 2 WKSTs previously running Windows 7 with Pulseway installed.  I am now at a loss as to how to re-add these units to my Pulseway instance.
      I see they are still showing up in the “Deployment Successful” tab under “Discovery & Deployment”.
      Is there a way to re-add these units without manually installing the Pulseway app on these WKSTs?
    • By RingTailedLemur7
      Hello, I have a question about the Pulseway app. When the pc is on all of the commands work great and are perfect for managing the pc. But I am attempting to turn on my pc when I am away from my home and then be able to fully control it like I was there. The issue is how the wake up command from sleep or from powered down will not work even when on my home network. How can I fix this. Also a side question, is there a way I would be able to see a live view of the screen or does it only allow screenshots of the screen. Thanks
    • By DQuiram
      We reinstalled Pulseway on a re-imaged system and after the install we noticed issues. In the patch mgmt section, the status was "assign failed" in red. We rebooted the system and then the service was not starting. We checked the service, it was set to start automatically and in the event log it was generating this error: "Service cannot be started.  The handle is invalid"  We removed the system from Pulseway, uninstalled, and reinstalled. Service is starting normally, but still getting the same issue of the patch policy failing to assign. I tried moving the system to another group that did not have a patch policy at all and got the same result. 
    • By Brant
      I've implemented a script that retrieves and stores the Windows Build Version number to a custom field in the system overview.   It works fine on MOST systems.  However, there are a small number systems that are unable to run the script.  The error message displayed includes: Start-Process : This command cannot be run due to the error: The system cannot find the file specified.
      I used the "Insert Output Variable Code" in the script and verified that it includes the inserted text "Start-Process -FilePath "$env:PWY_HOME\CLI.exe" -ArgumentList ("setVariable  .....".
      For some reason, a few systems do not seem to have the environment variable PWY_HOME set.
      It appears that these systems are using the Enable PowerShell User Impersonation option under Pulseway Manger > Settings > Runtime.
      What is the easiest way to make sure that all of my systems have the PWY_HOME variable set so that any future scripts will not fail because of a missing environment variable?
      Thanks,
      Brant
    • By devansh.gohil
      I had installed Pulseway and then wanted to delete it but I was not able to find Pulseway in the control panel uninstall feature and so I tried manually uninstalling files but that also did not work. I tried running the .msi installer again but an error came up saying that Pulseway is already installed but it still was not showing up. Please help me with this.
×
×
  • Create New...