What It Does
The script reads the members of the built-in Administrators group, found by its SID so it works on Windows installed in any language, compares each with AllowedMembers, writes one row per member, and alerts when any member is not approved.
A member whose SID no longer resolves, such as a deleted domain account or a PC moved between domains, makes the built-in command fail. Those are the members most worth finding, so the script reads the group through ADSI instead and reports them by SID.
Domain and Entra groups in the Administrators group are listed as one row each; their own members are not expanded. An approved entry matches the full name, the short name or the SID, ignoring case, with * and ? as wildcards. With no list, the built-in Administrator and Domain Admins are approved, matched by SID.
Before You Run It
- Write your approved list first. Giving a list replaces the defaults, so include the built-in Administrator if you want it approved.
- On Entra-joined PCs the Global Administrator and Device Administrator roles appear as SIDs. Approve them by SID.
- Approve a group by name or SID. The script cannot see who is inside 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 10 seconds.
- Example answer: "2 of 3 local administrators not approved: PC01\jsmith, S-1-5-21-1-2-3-1104"
- 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.
- AllowedMembers: Members allowed to be local administrators, separated by commas, e.g. "Administrator, CONTOSO\Domain Admins, CONTOSO\Desk Techs". Default empty: the built-in Administrator and Domain Admins, matched by SID.
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.