7 Mart 2013 Perşembe

Remove User Account and Group From Local Administrators Script


------------------------------------------------------------------

On Error Resume Next

' group name to remove user from
Set oGroupAdm = GetObject("WinNT://./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
---------------------------------------------------------------