Find Local Administrators on Computer

This will tell you all usersthat are in the Local Administrators group on a system.

Source Code

This script has not been checked by Spiceworks. Please understand the risks before using it.

1

2

3

4

5

6

7

8

9

10

11

12

13

14

15

16

17

18

19

20

21

22

23

24

25

26

27

28

29

30

31

32

33

34

35

36

37

38

39

40

41

42

43

44

45

46

47

48

49

50

51

'''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''' List local admin users '' '' Description: Finds a list of local admin users on a Windows '' machine '' Author: C. Peter Chen, http://dev-notes.com '' Version Tracker: '' 1.0 20081021 Base version ''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''optionexplicitdimarrRealAdmins'''''''''''''''''' Configuration ''''''''''''''''''arrRealAdmins=Array("Administrator","Domain Admins")' List of users that *are* supposed to be administrators; we'll ignore these people later'''''''''''''''''''''' End configuration ''''''''''''''''''''''dimadminGroup,groupMember,retfunctionisPermitedAdmin(MemberName)dimifori=lbound(arrRealAdmins)toubound(arrRealAdmins)ifucase(MemberName)=ucase(arrRealAdmins(i))thenisPermitedAdmin=trueexitfunctionendifnextisPermitedAdmin=falseendfunctionsetadminGroup=getObject("WinNT://./Administrators, group")foreachgroupMemberinadminGroup.membersifnotisPermitedAdmin(groupMember.name)thenret=ret&groupMember.name&","endifnextifret=""thenmsgbox("No invalid local administrators found.")elseret=mid(ret,1,len(ret)-1)' To get rid of the last commamsgbox("The following users are in the local admin group: "&vbcrlf&ret)endif