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.
Microsoft (R) Windows Script Host Version 5.7
Copyright (C) Microsoft Corporation. All rights reserved.
Administrators group members:
Name: Domain Admins