We help IT Professionals succeed at work.

Batch script to delete all users from domain admin group but administrators

1,322 Views
Last Modified: 2015-01-14
Hi Guys,

What I wanna achieve is same as mentioned here - http://blogs.technet.com/b/heyscriptingguy/archive/2005/12/12/how-can-i-delete-everyone-except-the-administrator-and-the-domain-admins-group-from-the-local-administrators-group.aspx but how do I do it from a batch script.

I know the command to add administrators is
net localgroup administrators /add "domain\user", but I want a script that will delete all users from administrators group, even ones that are unknown and we dont want to use Group Policy for this.
Comment
Watch Question

End-user support
CERTIFIED EXPERT
Commented:
This problem has been solved!
(Unlock this solution with a 7-day Free Trial)
UNLOCK SOLUTION
NVITEnd-user support
CERTIFIED EXPERT

Commented:
Hi manav08,
Did the solution help you? If so, I'd appreciate you closing the question appropriately.

Author

Commented:
Apologies for my laziness in closing this question.
I havent tested but believe this is solution we were after