VB Script to remove all users from the local administrators group
Posted on 2009-03-30
I have a script that works pefectly for cleaning up all users on remote PC's located in the local administrators group. At least on all the test PC's(which are in the domain). When I run the script on non test PC's, it seems to clean some and skip others. There seems to be no rhyme or reason that I can see. I have tested with users logged on, not logged on, no rights, power user rights, admin rights..no difference.
So, just curious if anyone has run into this problem before. The current code is shown here that does the clean:
For Each objUser In objGroup.Members
Select Case objUser.Name
Case "Administrator" strAction = "Nothing"
Case "Domain Admins" strAction = "Nothing"
Case "RegionAAdmins" strAction = "Nothing"
Case "RegionBAdmins" strAction = "Nothing"
Case "RegionCAdmins" strAction = "Nothing"
Case "RegionDAdmins" strAction = "Nothing"
Case Else objGroup.Remove(objUser.AdsPath)
I have even changed the last line from Remove(objUser.AdsPath) to Delete...no change.
Any suggestions would be greatly appreciated!!