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 AdministratorsstrComputer = objArgs(0)'Here we are saying that the first argument that is passed to our script by the user should be assigned to strComputerWScript.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.MembersWScript.Echo vbCrLf & " Name: " & objMember.Name 'Echoing out each member name and then a carriage return.Next
C:\Users\bradrutk\Desktop>test.vbs ServerXMicrosoft (R) Windows Script Host Version 5.7Copyright (C) Microsoft Corporation. All rights reserved.
Computer: ServerXAdministrators group members:
Name: Domain Admins