delete/remove users from local administrators grou
should help - create a dummy local admin user and test
Code:
' computer name or ip address
sNode = "."
' suppress errors
On Error Resume Next
' group name to remove user from
Set oGroupAdm = GetObject("WinNT://" & sNode & "/Administrators")
' loop through all members of the Administrators group
For Each oAdmGrpUser In oGroupAdm.Members
' get the name and make it lowercase
sAdmGrpUser = LCase(oAdmGrpUser.Name)
' Leave administrator and Domain Admins alone
' use lowercase letters in the names in the If statement!
If (sAdmGrpUser <> "administrator") And (sAdmGrpUser <> "domain admins") Then
msgbox oAdmGrpUser.Name
' remove users from Administrators group
oGroupAdm.Remove oAdmGrpUser.ADsPath
End if
Next If you leave the sNode variable as sNode = "." that will tell it to select the computer it is on when it runs ( sort of like a localhost or 127.0.0.1 ) kind of thing.
The rest of the script should take care of removal of local admin rights as long as the users are not the administrator or domain admins as per this line
Code:
If (sAdmGrpUser <> "administrator") And (sAdmGrpUser <> "domain admins") Then
So if your local admin accounts are named something else then you may want to amend the above mentioned line to suit your needs
Just found this script which is an improvement
Code:
Option Explicit
Dim network, group, user
Set network = CreateObject("WScript.Network")
Set group = GetObject("WinNT://" & network.ComputerName & "/Administrators,group")
For Each user In group.members
If UCase(user.name) <> "ADMINISTRATOR" And UCase(user.name) <> "DOMAIN ADMINS" Then
group.remove user.adspath
End If
Next