English
+370 5 205 5502 sales@monovm.com

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.

16

Jun, 19

Removing Users and Groups in Windows Through PowerShell

(26 ratings)

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

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

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

What about removing groups? 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.

Sometimes we just want to remove a certain user from a group 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.

user monovm

Mercedes

2019, Jul, 19

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