View, add, and remove user accounts with PowerShell

Environment

PSVersion 5.1.14409.1012

Check, add, and remove accounts

Start PowerShell with administrator privileges.

First, check what kind of local groups you have.

PS> Get-LocalGroup
 
Name                                           Description
----                                           -----------
Omission
Administrators                                 コンピューター/ドメインに完全なアクセス権があります

Check

Use Get-LocalGroupMember to check the members of Administrators.

Get-LocalGroupMember -Group Administrators

Add

Use Add-LocalGroupMember to add a member.

Add-LocalGroupMember -Group Administrators -Member EXAMPLE_USER

Remove

Use Remove-LocalGroupMember to remove a member.

Remove-LocalGroupMember -Group Administrators -Member EXAMPLE_USER

How to find out the command to manipulate accounts.

Use Get-Command with -Module Microsoft.PowerShell.LocalAccounts.

PS> Get-Command -Module Microsoft.PowerShell.LocalAccounts
 
CommandType     Name                                               Version    Source
-----------     ----                                               -------    ------
Cmdlet          Add-LocalGroupMember                               1.0.0.0    Microsoft.PowerShell.LocalAccounts
Cmdlet          Disable-LocalUser                                  1.0.0.0    Microsoft.PowerShell.LocalAccounts
Cmdlet          Enable-LocalUser                                   1.0.0.0    Microsoft.PowerShell.LocalAccounts
Cmdlet          Get-LocalGroup                                     1.0.0.0    Microsoft.PowerShell.LocalAccounts
Cmdlet          Get-LocalGroupMember                               1.0.0.0    Microsoft.PowerShell.LocalAccounts
Cmdlet          Get-LocalUser                                      1.0.0.0    Microsoft.PowerShell.LocalAccounts
Cmdlet          New-LocalGroup                                     1.0.0.0    Microsoft.PowerShell.LocalAccounts
Cmdlet          New-LocalUser                                      1.0.0.0    Microsoft.PowerShell.LocalAccounts
Cmdlet          Remove-LocalGroup                                  1.0.0.0    Microsoft.PowerShell.LocalAccounts
Cmdlet          Remove-LocalGroupMember                            1.0.0.0    Microsoft.PowerShell.LocalAccounts
Cmdlet          Remove-LocalUser                                   1.0.0.0    Microsoft.PowerShell.LocalAccounts
Cmdlet          Rename-LocalGroup                                  1.0.0.0    Microsoft.PowerShell.LocalAccounts
Cmdlet          Rename-LocalUser                                   1.0.0.0    Microsoft.PowerShell.LocalAccounts
Cmdlet          Set-LocalGroup                                     1.0.0.0    Microsoft.PowerShell.LocalAccounts
Cmdlet          Set-LocalUser                                      1.0.0.0    Microsoft.PowerShell.LocalAccounts

Microsoft.PowerShell.LocalAccounts is in the source of the result of Get-Command Get-LocalGroup.

PS> Get-Command Get-LocalGroup
 
CommandType     Name                                               Version    Source
-----------     ----                                               -------    ------
Cmdlet          Get-LocalGroup                                     1.0.0.0    Microsoft.PowerShell.LocalAccounts