Removing Users and Groups Through PowerShell

One of the many functions of PowerShell is management of users and user groups. Learn how to remove users from a group, remove groups and more.

Updated: 14 Dec, 21 by Ayden I 2 Min

PowerShell is a tool for system and network administrators with countless usages. One of them is the management of users and groups. throughout this tutorial, you will learn how to remove users or groups through PowerShell commands. Please keep in mind that this tutorial is written based on PowerShell 5.1 and should work with future releases. This version of PowerShell comes pre-installed on Windows 10 and Windows Server 2016

Here are the commands you're going to be using for these tasks.

  • Remove-LocalUser
  • Remove-LocalGroupMember
  • Remove-LocalGroup

1. let us start with removing a user in PowerShell. This is done with the Remove-LocalUser command.

Here's the syntax: Remove -LocalUser -Name “Username” where Username is the user's account name.

 

2. What about removing groups in PowerShell? This can also be done through PowerShell using the Remove-LocalGroup command.

The syntax: Remove-LocalGroup -Name “GroupName” where GroupName is the name of the group.

 

3. Sometimes we just want to remove a user from a group in PowerShell without completely deleting the user. This is also a task that could be accomplished through PowerShell's cmdlets. The most suitable one for it would be Remove-LocalGroupMember.

 

The syntax is as follows: Remove-LocalGroupMember -Group “GroupName” -Member “UserName” 

That is all for this tutorial, however, to learn more about PowerShell you can check out our extensive knowledgebase. Along with other PowerShell tutorials, you will also find the latest IT news and informative articles on related topics.

https://monovm.com/blog/create-local-user-with-powershell/

https://monovm.com/blog/add-users-to-local-group-with-powershell/

https://monovm.com/blog/creating-local-groups-with-powershell-command/

user monovm

Mercedes

2019, Jul, 19

I am actually thankful to the owner of this site who has shared this impressive article at here.

user monovm

Erna

2020, Jan, 20

Hi there to all, how is all, I think every one is getting more from this site, and your views are pleasant for new users.