Get-LocalUser
Gets local user accounts.
Syntax
Get-LocalUser
[[-Name] <String[]>]
[<CommonParameters>]
Get-LocalUser
[[-SID] <SecurityIdentifier[]>]
[<CommonParameters>]
Description
The Get-LocalUser
cmdlet gets local user accounts. This cmdlet gets default built-in user
accounts, local user accounts that you created, and local accounts that you connected to Microsoft
accounts.
Note
The Microsoft.PowerShell.LocalAccounts module is not available in 32-bit PowerShell on a 64-bit system.
Examples
Example 1: Get an account by using its name
This example gets a user account named AdminContoso02.
Get-LocalUser -Name "AdminContoso02"
Name Enabled Description
---- ------- -----------
AdminContoso02 True Description of this account.
Example 2: Get an account that is connected to a Microsoft account
This example gets a user account that is connected to a Microsoft account. This example uses a placeholder value for the username of an account at Outlook.com.
Get-LocalUser -Name "MicrosoftAccount\username@Outlook.com"
Name Enabled Description
---- ------- -----------
MicrosoftAccount\username@outlook.com True Description of this account.
Example 3: Get an account that has the specified SID
This example gets a local user account that has the specified SID.
Get-LocalUser -SID S-1-5-21-9526073513-1762370368-3942940353-500
Name Enabled Description
---- ------- -----------
Administrator True Built-in account for administering the computer/domain
Parameters
-Name
Specifies an array of names of user accounts that this cmdlet gets. You can use the wildcard character.
Type: | String[] |
Position: | 0 |
Default value: | None |
Accept pipeline input: | True |
Accept wildcard characters: | True |
-SID
Specifies an array of security IDs (SIDs) of user accounts that this cmdlet gets.
Type: | SecurityIdentifier[] |
Position: | 0 |
Default value: | None |
Accept pipeline input: | True |
Accept wildcard characters: | False |
Inputs
You can pipe a string to this cmdlet.
You can pipe a SID to this cmdlet.
Outputs
System.Management.Automation.SecurityAccountsManager.LocalUser[]
This cmdlet returns local user accounts.
Notes
The PrincipalSource property on LocalUser, LocalGroup, and LocalPrincipal objects describes the source of the object. The possible sources are as follows:
- Local
- Active Directory
- Azure Active Directory group
- Microsoft Account
PrincipalSource is supported only by Windows 10, Windows Server 2016, and later versions of the Windows operating system. For earlier versions, the property is blank.
Related Links
Feedback
Submit and view feedback for