How to list who belong to a local administrator group in windows 2000

Posted on 2006-05-17
Medium Priority
Last Modified: 2011-10-03
Currently we have several users in our windows 2000 domain and windows 2000 desktops that are part of the Local Administrator Group on their own machines.

I need a script that can walk the windows 2000 desktop computers in my domain either doing a query to the AD about member computers or i can tell the script an IP range. The the script will tell me who (a group or a user) belongs to that machine's Local Administrator Group or is equivalent to a local administrator.

Note that they are *not* domain admins. They are admins, but only on their own machines. and I want to remove that priviledge but going thru 200+ computers is a real pain.

The report should be dumped to a text file.

If that solution already exists as a vbscript, please let me know where.

Note: I am not an expert vbscript programmer.

Question by:eaperezh
  • 4
  • 2
LVL 15

Expert Comment

ID: 16704971

Author Comment

ID: 16708582
Sorry, JackOfPH, but what kind of answer is that?
LVL 16

Expert Comment

ID: 16709672
This script is meant to run as a computer startup script.

It will enumerate the local Admin group and place all entries into a comma seperated file.
You will have Enter the path for this file into the script where indicated.

Right now the entry for Administrator and Domain Admins will not be logged.

The text file will end up looking like this
computerName, User1, User2

Copy and paste it into notepad and save it w/ a .vbs extension
Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

LVL 16

Accepted Solution

mdiglio earned 2000 total points
ID: 16709677
ForAppending = 8

Dim strInAdmin, i, strUser
Set WshShell = CreateObject("WScript.Shell")
Set objFSO = CreateObject("Scripting.FileSystemObject")

'!!Create a text file in a shared folder that users can write to
'!! and place the path in quotes here:
Set objTextFile = objFSO.OpenTextFile("c:\InAdminGroup.txt", ForAppending, True)

Set objComputer = CreateObject("WScript.Network")
'Get Computer Name
strComputer = objComputer.ComputerName
Set colGroups = GetObject("WinNT://" & strComputer & "")
' Pull Environment variables for computer name
strComputer = WshShell.ExpandEnvironmentStrings("%COMPUTERNAME%")

colGroups.Filter = Array("group")
'Loop through groups
For Each objGroup In colGroups
      'only enumerate Admin group
      If objGroup.Name = "Administrators" Then
            For Each objUser In objGroup.Members
                  strUser = objUser.Name
                  If strUser <> "Administrator" And strUser <> "Domain Admins" Then
                        strInAdmin = strInAdmin & "," & objUser.Name
                  End If
            'If there are users in Admin group other than specified write it to the file
            If strInAdmin <> "" Then
                  objTextFile.WriteLine strComputer & strInAdmin
            End If
      End If
LVL 16

Expert Comment

ID: 16709702
I forgot to change line 9.
Instead of
Set objTextFile = objFSO.OpenTextFile("c:\InAdminGroup.txt", ForAppending, True)
it should be
Set objTextFile = objFSO.OpenTextFile("\\server\share\yourtextfile.txt", ForAppending, True)

Author Comment

ID: 16711682

Just ot let u know, when your're working with a mixture of English and in my case, Spanish operating systems, the name of the group is "administradores" instead of "administrators".

Many many thanks,
LVL 16

Expert Comment

ID: 16713717
Glad it worked for you!

Featured Post

Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Background What I'm presenting in this article is the result of 2 conditions in my work area: We have a SQL Server production environment but no development or test environment; andWe have an MS Access front end using tables in SQL Server but we a…
This article describes some techniques which will make your VBA or Visual Basic Classic code easier to understand and maintain, whether by you, your replacement, or another Experts-Exchange expert.
Get people started with the process of using Access VBA to control Outlook using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Microsoft Outlook. Using automation, an Access applic…
Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that a…
Suggested Courses
Course of the Month16 days, 13 hours left to enroll

864 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question