Find out the members of the local administrator group remotely.


 

Want to find out who is in the admin group on a box in your domain and don’t have privileges to logon?

So I’ve found myself in a spot where I need to find out who owns a box and I don’t have administrators privileges to logon and find out whose in the admin group myself.  In these instances it might be difficult to find out who you should contact to resolve an issue.

Just today, someone contacted us asking who owns the DHCP service on ServerX.  Well ServerX is not something I have access to, so the easiest way is to look at the administrators group on the machine and contact them. 

 I mean, how often do you own a server and not throw yourself in the admin group?  Here’s a simple script that will enumerate the members of the administrator group remotely.  You can obviously adjust the string or strGroup to point to whatever group your interested in.  Just supply the computer your after as the first and only argument and away you go! 

 

‘Just copy this into notepad and save as whatever.vbs

set objArgs = WScript.Arguments ‘This tells us that we want to acept arugments for our script

strGroup = “Administrators” ‘We’re setting strGroup to be equal to Administrators

strComputer = objArgs(0)‘Here we are saying that the first argument that is passed to our script by the user should be assigned to strComputer
WScript.Echo “Computer: ” & strComputer ‘Now we’re just echoing out the computer name

Set objGroup = GetObject(“WinNT://” & strComputer & “/” & strGroup & “, group”)
WScript.Echo ” ” & strGroup & ” group members:”

For Each objMember In objGroup.Members
WScript.Echo vbCrLf & ” Name: ” & objMember.Name ‘Echoing out each member name and then a carriage return.
Next

 

SAMPLE OUTPUT:

C:\Users\bradrutk\Desktop>test.vbs ServerX
Microsoft (R) Windows Script Host Version 5.7
Copyright (C) Microsoft Corporation. All rights reserved.

Computer: ServerX
Administrators group members:

Name: Domain Admins

Name: users_group

Name: Bradrutk

Name: MattS


Comments (6)

  1. Anonymous says:

    There is a tools (local.exe) in Windows 2000 Resource Kit can help you display member of administrators group remotely from command line.

    You will only need to type following command to display member of administrators group:

    local administrators \computername

  2. Anonymous says:

    Information that would have been useful to me yesterday! (Wedding Singer)

  3. Jim Cauble says:

    This is great, thanks for making it available!

  4. rodhack says:

    Under an amendment if administrators want to add them to excel:

    Set objExcel = CreateObject(“Excel.Application”)
    set objArgs = WScript.Arguments ‘This tells us that we want to acept arugments for our script
    objExcel.Visible = True
    objExcel.Workbooks.Add
    intRow = 2
    intcolumn = 2

    objExcel.Cells(1, 1).Value = “Nombre Servidor”
    objExcel.Cells(1, 2).Value = “Administradores Locales”

    Set Fso = CreateObject(“Scripting.FileSystemObject”)
    Set InputFile = fso.OpenTextFile(“D:SCRIPTSBuscar_AdministradoresMachineList.Txt”)
    strGroup = “Administrators” ‘We’re setting strGroup to be equal to Administrators

    Do While Not (InputFile.atEndOfStream)
    HostName = InputFile.ReadLine
    Set objGroup = GetObject(“WinNT://” & HostName & “/” & strGroup & “, group”)
    Set WshShell = WScript.CreateObject(“WScript.Shell”)
    objExcel.Cells(intRow, 1).Value = HostName
    For Each objMember In objGroup.Members
    objExcel.Cells(intRow, intcolumn).Value = vbCrLf & objMember.Name ‘Echoing out each member name and then a carriage return.
    intcolumn = intcolumn + 1
    Next
    intcolumn = 2
    intRow = intRow + 1
    Loop

    objExcel.Range(“A1:B1”).Select
    objExcel.Selection.Interior.ColorIndex = 19
    objExcel.Selection.Font.ColorIndex = 11
    objExcel.Selection.Font.Bold = True
    objExcel.Cells.EntireColumn.AutoFi

  5. rodhack says:

    Under an amendment if administrators want to add them to excel:

    http://sdrv.ms/1dTHLzZ

  6. Rob says:

    Doesn’t work in win 8.1 client or host