→ 🚀What's New? Explore Lansweeper's Fall 2024 Updates! Fall Launch Blog !
‎05-26-2015 06:59 PM
Solved! Go to Solution.
‎05-26-2015 08:06 PM
‎05-28-2015 03:38 PM
‎05-28-2015 02:42 PM
‎05-26-2015 10:53 PM
On Error Resume Next
CName = "."
f1 = 0
f2 = 0
'group name to remove users from
Set LocAdmGroup = GetObject("WinNT://" & CName & "/Administrators")
' loop through all members of the Administrators Group
For Each AdmGrpUser In LocAdmGroup.Members
f1=f1+1
IF (AdmGrpUser.Name <> "Administrator") And (AdmGrpUser.Name <> "Domain Admins") And (AdmGrpUser.Name <> "poweruser") Then
f2=f2+1
IF f2=1 then
Wscript.Echo "Removed Domain Users from Local Administrators Group"
End IF
Wscript.Echo AdmGrpUser.Name
' remove users from Administrators group
LocAdmGroup.Remove AdmGrpUser.ADsPath
End IF
Next
IF f1=2 Then
Wscript.Echo "Domain Users Weren't Found in Local Administrators Group!"
End IF
If err.number<>0 then
WScript.Echo "Script Check Failed"
Wscript.Quit 1001
Else
WScript.Echo "Script Check Passed"
Wscript.Quit 0
End If
‎05-26-2015 09:49 PM
‎05-26-2015 08:06 PM
Experience Lansweeper with your own data. Sign up now for a 14-day free trial.
Try Now