How to manage Local Users and Groups using Windows PowerShell

How to manage Local Users and Groups using Windows PowerShell

Windows PowerShell can also be used to manage users and local groups. This confirms the principle of Windows 10 as a multi-user operating system. There are other GUI-based utilities for managing local users and groups. However, some system administrators can use the command-line utility to manage these users and groups. That's what we will learn more in this guide.

Manage local users and groups by using Windows PowerShell

We will now cover this guide in two parts. They are:

  1. Local user management.
  2. Management of user groups.

To get started, you need to open Windows PowerShell as an administrator.

1) Local user management

This The cmdlet will help you find all the details on all local user accounts. These details will include the account name, the activated status and the description. The cmdlet is:

Get-LocalUser

You can also get custom data on various objects related to your account. For example, we used an object to check when the password for the local account was last defined. The cmdlet we used was:

Get-LocalUser -Name root | Select-Object PasswordLastSet

The skeleton of this cmdlet is:

Get-LocalUser -Name root | Select-Object *

And you can use objects such as the following to get different kinds of information prepared just for you:

  • AccountExpires
  • Description
  • Enabled : True
  • FullName
  • PasswordChangeableDate
  • PasswordExpires
  • UserMayChangePassword
  • PasswordRequired
  • PasswordLastSet
  • LastLogon
  • Name
  • SID
  • PrincipalSource
  • ObjectClass

2) Manage groups of users

This cmdlet will help you find all the details about all groups of local user accounts:

Get-LocalGroup

If you want to create a new group of local users, use this cmdlet:

New-LocalGroup -Name  -Description ''

Now, to add local user accounts to a particular group, you can use this cmdlet:

Add-LocalGroupMember -Group '') -Verbose

You can also use this cmdlet for the same reasons:

Get-Localuser -Name john | Add-LocalGroupMember -Group '' 

And to view all user accounts that are part of a particular group, use this command:

Get-LocalGroupMember -Group ''

Finally, if you want to delete a local user account from a group, use this cmdlet:

Remove-LocalGroupMember -Group '' –Member 

Here are some of the basic management cmdlets that allow a user to manage local users and groups by using Windows PowerShell.

I hope you found this guide useful.

Leave a Reply