Category filter

Script to automatically log in to a user account on Windows

You can run PowerShell scripts to carry out a wide range of administrative tasks on your Windows endpoints. For example, executing this PowerShell script can remotely unlock your Windows PC so that the device end-user can automatically sign in to the device without entering any credentials. That’ll be useful for users when in a trusted environment as they won’t be inconvenienced by a lock screen every time they need to log in to the device. You can also use this script when a user’s device needs to be temporarily shared with another user without having to share the device password.

With Hexnode, you can seamlessly push custom scripts remotely on your Windows devices using the Execute Custom Script action.


The Sample Scripts provided below are adapted from third-party Open-Source sites.

PowerShell script to automatically log in to a user account on Windows

This script requires two Arguments:

  1. Username of the account to be signed in.
  2. Password associated with the account.

Place the above two arguments in the Arguments box, separated using spaces. The device will automatically be restarted on executing the script successfully to apply the changes. On restarting, the user will get automatically signed in to the user account.

The device will continue signing in to the user account automatically every time you turn on the device or sign out from the account, effectively locking out all the other user accounts present on the device. Therefore, you can also use this script in a kiosk environment to prevent users from signing out of the kiosk user account.


After executing this script, anyone who has physical access to the device can access all the contents on the device and even view the password associated with that user account from the Windows registry. So, ensure that necessary steps have been implemented to avoid any potential security vulnerabilities.

To disable automatic sign-in on the device, you can execute the PowerShell script below:


  • It is recommended to manually validate the script execution on a system before executing the action in bulk.
  • Hexnode will not be responsible for any damage/loss to the system on the behavior of the script.

  • Sample Script Repository