Skip to content
Menu

Local User Accounts on This PC

Lists every local account with enabled state, last logon, password age and settings, and administrator membership, with a Flags column for what needs a look.

Local user accounts on this PC is free for members.

Enter your email to create your free account and get the file.

We'll email you the script and the weekly MSP Outpost email. Unsubscribe anytime. Privacy policy.

Already a member? Sign in.

Be the first to review Local user accounts on this PC. Tell other MSPs how it worked for you.

Write a Review

LanguagePowerShell
Runs onWindows 10, Windows 11, Windows Server 2016+; runs as SYSTEM
NeedsPowerShell 5.1, administrator rights
Read-onlyReads, changes nothing

What It Does

The script is read-only. It reads every local account, not domain or Entra accounts, and writes one row each with the name, SID, whether it is enabled, last logon, when the password was last set, whether the password never expires, whether a password is required, whether it is a member of the local Administrators group, and its description.

The Flags column names what needs a look. BuiltinAdminEnabled means the built-in Administrator, the account whose SID ends in -500 whatever it is renamed to, is enabled. PasswordNeverExpires marks an enabled account whose password never expires. Stale marks an enabled account whose last logon on this PC was more than StaleDays ago, or that never logged on and either has no password-set date or last set it more than StaleDays ago. NoPasswordRequired marks an enabled account that may have an empty password.

The last logon is the last time the account logged on to this PC, and it is not replicated. Times are UTC. The custom field receives the number of enabled local accounts that are members of the Administrators group. The status is OK, because a Report does not alert. Use test-local-user-hygiene when you want an alert.

Before You Run It

  • Use it to build an inventory first, then use test-local-user-hygiene to alert on the findings.
  • Set StaleDays to match the client's rules. The default is 90 days.
  • Remember domain and Entra accounts are not listed. Only local accounts are read.
  • Use ExportPath to save the table as a CSV for a review or an audit file.

Type and Risk

  • Type: Report. It collects facts into a table and never alerts. It exits 0, or 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: "6 local accounts (2 enabled); 1 enabled administrator; flagged: 1 password never expires, 1 stale"
  • 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.

  • StaleDays: Days without a logon before an enabled account is flagged Stale. Whole number, 1 to 3650. Default 90.

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.

The Script

get-local-users.ps1 · 834 lines · 42.5 KB

Free for Members

Create a free account or sign in to read, copy and download this script.

Welcome Back

Sign in to your MSP Outpost account.