What It Does
The script is read-only. It reads every local account and writes one row per finding, with Account, Sid, Finding and Detail, alerting with exit 1 when there is any.
BuiltinAdministratorEnabled means the built-in Administrator, the account whose SID ends in -500, whatever it is renamed to, is enabled, unless AllowBuiltinAdmin is true. GuestEnabled means the Guest account, SID ending -501, is enabled. NoPasswordRequired means the account setting does not require a password. The script does not test whether the password is empty. PasswordTooOld means an enabled local account whose password was set more than MaxPasswordAgeDays ago. Accounts that sign in with a Microsoft account are left out of this and the previous check, because their password is not managed on this PC.
SuspectName means an enabled account, other than the built-in Administrator, whose name matches one of SuspectPatterns, a sign of an old IT provider's leftover account, unless its name matches AllowedAccounts. AllowedAccounts affects only this finding: an approved account whose settings allow an empty password, or whose password is too old, is still reported.
Patterns are case-insensitive PowerShell wildcards and must keep at least 3 letters or digits, so * or a* is refused. Domain accounts are not looked at.
Before You Run It
- Add your own technician and break-glass account names to AllowedAccounts first.
- Review SuspectPatterns, which default to names such as *admin*, itsupport*, msp*, localadmin* and support*.
- Use get-local-users first if you want an inventory with no alerts.
- Schedule it in your RMM and alert on exit 1.
Type and Risk
- Type: Monitor. It checks one condition. It exits 1 when it finds the problem, so your RMM can alert on it, 0 when all is well, and 2 when it could not run.
- Risk: Low. It reads and changes nothing.
- Restart: It never restarts the machine.
- Typical run: Under 15 seconds.
- Example answer: "3 local account findings: Administrator: BuiltinAdministratorEnabled; msp-old: SuspectName; tech1: NoPasswordRequired"
- 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.
- AllowBuiltinAdmin: true when the built-in Administrator is allowed to be enabled (default false).
- MaxPasswordAgeDays: Oldest password age allowed, in days. Whole number, 1 to 36500. Default 365.
- SuspectPatterns: Comma, semicolon or newline separated name patterns that look like a former provider's account. Default "*admin*,itsupport*,msp*,localadmin*,support*".
- AllowedAccounts: Account names (wildcards allowed) that are approved and never reported as SuspectName. Default empty.
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.