Script Overview

Automates creating an autologon user and configures Windows for automatic login. After a specified time, it cleans up the autologon settings.

The original intent: an endpoint is joined to Entra and enrolled into Intune via Autopilot, but the customer only wanted the end user logging in to a local account. Joining the PC to Entra will default the login screen to prompt for a UPN in the joined tenant, which was not desired. This script creates a new local user, grants it local admin rights, sets it up as an autologon user temporarily (so the last-logged-in user is remembered), then removes the autologin setup after 30 minutes. A sloppy workaround, but it served the customer's need.

Steps

  • Step 0: Verify the script hasn't already run via a marker file.
  • Step 1: Create the local user and add to Administrators (prevent password change).
  • Step 2: Set registry values for autologon.
  • Step 3: Create a cleanup script in ProgramData.
  • Step 4: Schedule the cleanup task to run in 30 minutes under SYSTEM.
  • Step 5: Create the marker file.
  • Step 6: Restart the computer.

Security note

This script stores credentials in the registry temporarily. The cleanup task removes these sensitive values after 30 minutes.