In today’s digital age, managing users and groups efficiently is essential for smooth computer operations. Windows 11, Microsoft’s latest OS, offers robust tools for this purpose. One of these is PowerShell, which allows for streamlined user and group management. Below, we dive deep into managing local users and groups using PowerShell in Windows 11.
1. Get Local Users List Using PowerShell
To retrieve a list of local users:
Get-LocalUser
2. Getting User List, Local and Non-local
For a comprehensive list that includes both local and non-local users, combine local user data with Active Directory information:
Get-LocalUser Get-ADUser -Filter *
(Note: The latter command requires the Active Directory module.)
3. Add and Remove User Using PowerShell
- Adding a User:
New-LocalUser -Name "Username" -Description "Description of the User" -NoPassword
- Removing a User:
Remove-LocalUser -Name "Username"
4. Manage Groups Using PowerShell
- View all local groups:
Get-LocalGroup
- Create a new group:
New-LocalGroup -Name "GroupName" -Description "Description of the Group"
- Remove a group:
Remove-LocalGroup -Name "GroupName"
5. Manage Group Members Using PowerShell
- Add a member to a group:
Add-LocalGroupMember -Group "GroupName" -Member "Username"
- Remove a member from a group:
Remove-LocalGroupMember -Group "GroupName" -Member "Username"
- View members of a group:
Get-LocalGroupMember -Group "GroupName"