0

Is there a way through command line to remvoe all the users in a security group (from Local Users and Groups)?

I can remove a single user with "net localgroup", but I don't know who is in the group.

2
  • Why don't you just remove the entire group?
    – Ramhound
    Oct 11, 2012 at 17:04
  • I want to remove all the users that were entered in this groups every week. The group is still needed. Could I remove and re-create the group?
    – the_lotus
    Oct 11, 2012 at 18:41

1 Answer 1

1

A script would be a better solution but here is the command. (Don't forget to change groupname)

for /F "skip=6" %i in ('net localgroup groupname') do net localgroup groupname %i /delete

If you take a look at 'net localgroup groupname' structure you will see why I skip 6 tokens and that it produces an error at the end, because the last token is the confirmation that the command was successfully executed. As far as I know you need to write a script to get rid of that.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .