- Trending Categories
Data Structure
Networking
RDBMS
Operating System
Java
MS Excel
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
Physics
Chemistry
Biology
Mathematics
English
Economics
Psychology
Social Studies
Fashion Studies
Legal Studies
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
How to remove a member from the local group using PowerShell?
To remove a member from the local group using PowerShell, we can use the RemoveLocalGroupMember command. This command is available in the module Microsoft.PowerShell.LocalAccounts in and above PowerShell version 5.1.
To use this command, we need to provide two parameter values. One is the -Group (Local Group Name) and the second is -Member (Name of the Member to remove). For example,
Remove-LocalGroupMember -Group Administrators -Member TestUser
The above command will remove TestUser from the local group Administrators.
To use the above command on the remote computer, we need to use Invoke-Command. For example,
Invoke-Command -ComputerName Test1-Win2k12,Test1-Win2k16 -ScriptBlock{ Remove-LocalGroupMember -Group "Administrators" -Member "LabDomain\Alpha" }
The above command will remove LabDomain\Alpha user from the local Administrators group on remote computers.
If you don’t have the LocalAccounts module available or the PowerShell version is below 5.1 then you can use the cmd command as shown below.
net localgroup Administrators labdomain\alpha /delete
In the above example, labdomain\alpha will be removed from the local group Administrators using cmd command. You can execute this command remotely using Invoke-Command method,
Invoke-Command -ComputerName Test1-Win2k12,Test1-Win2k16 -ScriptBlock{ net localgroup Administrators labdomain\alpha /delete }
- Related Articles
- How to delete the local group from the windows system using PowerShell?
- How to create a new local group using PowerShell?
- How to get the local Administrators group members using PowerShell?
- How to add the user to the local Administrators group using PowerShell?
- How to Remove the computer from the AD domain using PowerShell?
- How to change the local disk name using PowerShell?
- How to get the azure resources from the resource group using PowerShell?
- How to get the list of local groups using PowerShell?
- How to change the local user account password using PowerShell?
- How to set the local user account settings using PowerShell?
- How to find the locked local user accounts using PowerShell?
- How to get the disabled local user accounts using PowerShell?
- How to create a new local user in windows using PowerShell?
- How to delete the Azure Resource Group using PowerShell?
- How to remove windows features using PowerShell?
