Category filter

Script to clear password on Windows

IT admins, from time to time, find themselves clearing/resetting passwords of various Windows devices enrolled in their organization. Such a scenario often arises when the employee forgets their password and needs help logging into their system or when the employee leaves the company without resetting the password themselves. But in a modern work scenario, where employees work with their devices from remote locations and thus are not easily accessible for the IT admin, custom scripts become the viable option to clear passwords. Hexnode helps IT admins deploy these scripts remotely to the endpoints using the Execute Custom Script action.

Disclaimer:


The sample scripts provided below are adapted from third-party open-source sites.

Batch script

Clear password for a specific user

This command resets the password for the local computer being used. Replace <username> with the local user account from which the password should be cleared.

PowerShell script

Clear password for a specific user

Replace username with the name of the local user account from which the password is to be cleared.

For example, to clear the password from the user account ‘John’ in the Windows device:

Set-LocalUser -name “John" -Password ([securestring]::new())

Notes:

  • 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