How to List All User Accounts on a Windows System Using PowerShell

In this post, I’ll show you how to list all the local users on a Windows system using PowerShell.

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.


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.

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'}

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 *


It is an essential part of data security to be able to understand what your users have permissions to have what they are doing with your critical files and folders. In order to do this in a way that isn’t too time consuming or manual, you’ll need a data security solution. Try LepideAuditor for free today!

Download LepideAuditor