Link to home
Start Free TrialLog in
Avatar of certuran
certuranFlag for Türkiye

asked on

How do I get list of members of Local Administrators group of computers or servers

I need a script.
How do I remotely get list of members of Local Administrators group of computers or servers.
Avatar of Lee W, MVP
Lee W, MVP
Flag of United States of America image

If you want to do it for the whole domain, this Microsoft provided Powershell script should do the trick:
http://gallery.technet.microsoft.com/Query-members-of-Local-d0f393a6

And there's a VB Script available from Microsoft that can do it for a single specified machine:
http://blogs.technet.com/b/brad_rutkowski/archive/2007/01/06/find-out-the-members-of-the-local-administrator-group-remotely.aspx
Avatar of certuran

ASKER

for single machine vbs giving error at row 3

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
ASKER CERTIFIED SOLUTION
Avatar of Mahesh
Mahesh
Flag of India image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Dear Mahesh,
very good.
psexec @C:\Computerlist.txt net localgroup administrators > C:\groupmembership.txt
in the C:\groupmembership.txt every machine do not have any mark that is belong to it is own.
only problem is this.
However I have that below. It solves my problem.

@echo off
for /F "usebackq delims==" %%I in ("Machines.txt") do Call :begin %%I
goto :EOF

:begin
set srv=%1
:get info

@echo %srv%

psexec \\%srv% ............
with psexec, net localgroup administrators command good solution. Also vbs can be used. Thank you