Skip to main content

Set Last Logged In User

Summary

This is an Automate implementation of the agnostic script Set-LastLoggedOnUser to manage the last logged-in user's information displayed on the Windows login screen.

Notes:

  • The user must have logged on to the computer at least once to be set on the login screen by this script.
  • It is mandatory to restart the computer to implement changes. The Reboot parameter can be used to forcefully restart the computer.
    • You can circumvent the need to reboot the machine if you are logged in while the script is running. Once you log out, the changes will be applied.

Sample Run

  • Clears the last logged-in user's information from the login screen. The computer must be restarted manually afterward to implement the changes.

    Sample Run 1

  • Clears the last logged-in user's information from the login screen and forcefully restarts the computer.

    Sample Run 2

  • Sets the specified local user as the last logged-in user. The computer must be restarted manually afterward to implement the changes.

    Sample Run 3

  • Sets the specified domain user as the last logged-in user and forcefully restarts the computer.

    Sample Run 4

Variables

NameDescription
ProjectNameSet-LastLoggedOnUser
WorkingDirectoryC:/ProgramData/_Automation/Script/Set-LastLoggedOnUser

User Parameters

NameExampleRequiredDescription
Clear1TrueClears the last logged-in user's information from the login screen.
UserNameDomain/UserNameTrueSets the specified username as the last logged-in user. The username should be in the format 'Domain/User' or 'User'.
DisplayNameUser NameFalseOptionally specifies the display name to set for the last logged-in user. If not provided, it defaults to the username.
Reboot1FalseOptionally restarts the computer to apply the changes immediately.

Output

  • Script log