Windows PowerShell can also be used to manage Local Users and Groups. This affirms to the principle of Windows 10 being a multiuser operating system. There are other GUI based utilities to manage Local Users and Groups. But some System administrators might like to use the command-line utility to manage these users and groups. That is what we are going to learn more about in this guide.
Manage Local Users & Groups using Windows PowerShell
We will be now covering this guide in two parts. They are the following:
- Managing Local Users.
- Managing the User Groups.
To begin, you will need to open Windows PowerShell as an Administrator.
1] Managing Local Users
This cmdlet will help you to find all the details about all the local user accounts. These details will include the Account Name, Enabled status, and the description. The cmdlet is:
You can also get customized data about various objects related to your account. For example, we had used an object to check when was the Local account’s password was set last time. The cmdlet we used was:
Get-LocalUser -Name root | Select-Object PasswordLastSet
The skeleton for this cmdlet is:
Get-LocalUser -Name root | Select-Object *
And you can use objects like the following to get different sorts of information curated just for you:
Enabled : True
2] Managing the User Groups
This cmdlet will help you to find all the details about all the groups of the local user accounts:
If you wish to create a new Local User Group, use this cmdlet:
New-LocalGroup -Name <NAME OF THE GROUP> -Description '<ENTER THE DESCRIPTION OF THE GROUP HERE>'
Now, in order to add Local User Accounts to a particular group, you can use this cmdlet:
Add-LocalGroupMember -Group '<NAME OF THE GROUP' -Member ('NAME 1','NAME 2','<ROLE>') -Verbose
Alternatively, this cmdlet can be used for the same reasons, too:
Get-Localuser -Name john | Add-LocalGroupMember -Group '<NAME OF THE GROUP>'
And to display all the User Accounts that are a part of a particular group, use this command:
Get-LocalGroupMember -Group ''
Lastly, if you wish to remove a local user account from a group, use this cmdlet:
Remove-LocalGroupMember -Group '<NAME OF THE GROUP>' –Member <NAME OF THE LOCAL USER ACCOUNT>
These are some of the basic managing cmdlets for a user to manage Local Users and Groups using Windows PowerShell.
I hope you found this guide useful.