What It Does
The script reads the account control flags and the supported Kerberos encryption types of every enabled user, and ALERTs when it finds one of five weak settings: NeverExpires, BlankPasswordAllowed (a blank password is allowed), ReversibleEncryption, DesKeyOnly and DesEncryptionTypes. Each weak setting is one row, with the account, whether it is enabled, whether it is a person or a service account, whether it alerts, and its OU.
A user with a service principal name is treated as a service account. A service account that never expires is listed with IsAlert false and does not raise the alert, unless FlagServiceAccounts is true. Every other weak setting alerts for both kinds, and the answer notes how many service accounts were left out of the count.
ExcludeAccounts skips accounts by exact sign-in name, with no wildcards. Disabled users are skipped unless IncludeDisabled is true, and computer accounts are not checked. SearchBase limits the check to one OU. With no weak setting the run ends OK.
It only reads. Fixing a setting is a decision for the account's owner, because removing never expires from a service account can break what runs as it.
Before You Run It
- Run it on a domain controller or a member server with the ActiveDirectory module (RSAT) and administrator rights.
- Run it once by hand and review the list before you schedule it as an alert.
- List accepted exceptions in ExcludeAccounts so the alert stays quiet until something new appears.
- Before clearing a flag on a service account, find out what runs as it.
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 30 seconds.
- Example answer: "5 weak setting(s) on 4 account(s): 2 never expires, 1 blank password allowed, 1 reversible encryption, 1 DES; first: jsmith"
- Tested before listing on a Windows Server 2025 domain controller (VM) 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.
- IncludeDisabled: true to also check disabled users. Default false.
- FlagServiceAccounts: true to also alert on service accounts (users with a service principal name) whose password never expires. Default false.
- ExcludeAccounts: Sign-in names to skip, separated by comma, semicolon or new line. No wildcards. Default empty.
- SearchBase: Only check users under this OU or container, as a distinguished name. Default empty: the whole domain. It must exist.
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.