PowerShell Get-LocalUser to List All Local Users on Windows

Get List of Local Users using Lepide Active Directory Auditor
x
Or Deploy With Our Virtual Appliance
4 min read | Updated On - December 22, 2023
In This Article

Being able to list all user accounts on a Windows system is crucial for security and management purposes. It allows administrators to identify all user accounts present, ensuring accountability for system actions and enabling prompt action in case of unauthorized activities or breaches. Regular auditing of user accounts helps maintain system security and control by promptly detecting and addressing suspicious or unidentified accounts.

Access control is improved as administrators can assign appropriate permissions and privileges to each account based on their roles. Password policies are enforced efficiently, reducing the risk of weak passwords and brute-force attacks. Troubleshooting becomes more effective, and technical support can diagnose and resolve user-specific issues better.

Compliance with regulations and data security requirements is facilitated through transparency and control over user access. Additionally, the feature aids in employee onboarding and offboarding, ensuring timely access provisioning and account disabling/removal for departing employees.

In essence, the “List All User Accounts” feature simplifies user management, enhances security, and streamlines administrative tasks, resulting in a more organized and secure Windows environment.

In this post, I’ll show you how to list all the local users on a Windows system using PowerShell. However, because this method of using PowerShell is both complex and time consuming, I’ll also show you an alternative, more straightforward method using Lepide Auditor for Active Directory.

Use Get-LocalUser PowerShell cmdlet to List All User Accounts

The Get-LocalUser PowerShell cmdlet lists all the local users on a device. Remember that Active Directory domain controllers don’t have local user accounts.

Get-LocalUser

If you want to see all the parameters available, pipe the results to the Select cmdlet:

Get-LocalUser | Select *

Running the cmdlet without any parameters returns all accounts but you can also add the -Name or -SID parameters to return information about a specific account. The command below returns the user account with security identifier (SID) S-1-5-2.

Get-LocalUser PowerShell cmdlet
Figure 1
Get-LocalUser -SID S-1-5-2

Get-LocalUser is limited to listing accounts on the system where the command is run. But Get-WmiObject queries local users on remote systems using Windows Management Instrumentation (WMI).

Get-WmiObject -ComputerName workstation1 -Class Win32_UserAccount -Filter "LocalAccount=True"

The output can be piped to Select to display just the information you need, and then piped to Out-GridView to display it in separate window with the ability to sort and filter the information.

Get-WmiObject -ComputerName workstation1 -Class Win32_UserAccount -Filter "LocalAccount=True" | Select PSComputername, Name, Status, Disabled, AccountType, Lockout, PasswordRequired, PasswordChangeable | Out-GridView

Most people associate ADSI with Active Directory, but it can also be used to enumerate local accounts.

$adsi = [ADSI]"WinNT://workstation1"
$Users = $adsi.Children | where {$_.SchemaClassName -eq 'user'}
$Users

The above code displays information about all the users on workstation1. You can add a number after the $Users variable to display each user individually. Adding a zero displays information about the first user, and a ‘1’ about the second user, and so on.

$Users[0] | Select *

How Lepide Helps

The native PowerShell method for listing all user accounts requires knowledge of PowerShell scripting and is a time-consuming process.

An alternative is to use Lepide Auditor for Active Directory. The Lepide Solution provides an All Users Report which allows you to list all users quickly and easily without the need for any PowerShell scripting expertise.

Here is an example of the report:

all users report

The All Users Report is straightforward to run using the following steps:

  • From the States and Behavior screen, expand Active Directory Reports, User Reports and then choose the All Users
  • Click Generate Report
  • The report can be filtered, grouped, exported and saved

It is an essential part of data security to be able to understand what your users have permissions to and what they are doing with your critical files and folders. To do this in a straightforward way, you’ll need a data security solution like Lepide Auditor for Active Directory, Try it for free today!

Check out Lepide Active Directory Auditing solution for free
x
Or Deploy With Our Virtual Appliance
Learn More...

Get List of Local Users using Lepide Active Directory Auditor

x
Or Deploy With Our Virtual Appliance
Learn More...