What It Does
The script sets a new random 20-character password on one local account. With AccountName empty, the default, it is the built-in Administrator, found by its SID, the local account whose SID ends in -500, even if it was renamed. It may be disabled, and the script does not enable it or change anything except the password. With AccountName set, it is that local account, which must exist. An account that Windows LAPS manages is skipped.
Each successful real run rotates the password, so a second successful run replaces the first password in the field. DryRun previews the rotation without changing the password. The password comes from the operating system's cryptographic random number generator and has upper case, lower case, digits and symbols. It is written to the RMM field before it is set, so a failed field write leaves the account untouched. Afterwards it checks the password change time, and for an enabled account tries one test logon, which security baselines often deny, so a failed test is only a warning.
The password is never printed. It is not in the output, the answer, the data rows, the change log or the exported file. It is written only to the RMM custom field named by ResultField, and NinjaOne, Datto RMM and Syncro are supported. Make that a secure field. Without ResultField, or on an RMM it cannot write to, it refuses before changing anything, and OutputFormat Answer is refused for the same reason.
A domain controller has no local accounts, and the script ends in ERROR there. It does not touch group membership, expiry settings or sessions. Programs, scheduled tasks and services that run as the account with the old password will fail to sign in, so use it on break-glass and built-in accounts, not on accounts something depends on.
Before You Run It
- Create a secure custom field in your RMM first, and pass its name as ResultField.
- Check what runs as the account before you rotate it. Services and tasks using the old password will fail.
- Check who can read that field in your RMM. It holds a working administrator password.
- Use new-local-admin-account to create a separate break-glass account instead.
Type and Risk
- Type: Action. It makes its change, checks the change worked and says what changed. It exits 0, or 2 when it could not do the job.
- Risk: Low. Set DryRun=true, or run it with -WhatIf, to list every change without making any.
- What it changes: Sets a new password on one local user account and writes it to the RMM custom field.
- Restart: It never restarts the machine.
- Typical run: Under 15 seconds.
- Example answer: "Password for local account Administrator rotated; password written to field LocalAdminPassword"
- Tested before listing on Windows 11 with Windows PowerShell 5.1, run as SYSTEM, against its own test cases.
Inputs
Pass an input as an argument (-Name value), as an environment variable with the same name, which is how most RMMs pass script variables, or change its default in the param() block at the top of the script. An argument wins over an environment variable, which wins over the default.
- AccountName: The local account to rotate. Default empty: the built-in Administrator (SID ending in -500).
Every script also takes DryRun, OutputFormat (Text, Answer, Json or Csv), ExportPath and ResultField, which writes the answer to an RMM custom field.
License
Provided "as is" under the MIT License, without warranty of any kind. Test before production use. MSP Outpost and User First Digital Inc. accept no liability for any damage or loss.