Click here to get back home

How to list member of local admin

 HomeNewsGroups | Search | About
 microsoft.public.windows.server.security    Post an article   get this group's latest topics as an RSS feed add this group's latest topics to your My MSN content add this group's latest topics to your My Yahoo content
Subject Author Date
How to list member of local admin Mahmood 02-06-2008
Posted by Mahmood on February 6, 2008, 1:23 pm
Please log in for more thread options
I am looking for a VB Script to list member of local admin group for my
servers in my domain.

Example
Domain=contoso
Server OU=Servers
ServerA, Server B ......................

I want to list member of local admin for all the servers.

Thx,
MA

Posted by Marcin on February 10, 2008, 10:21 am
Please log in for more thread options
Mahmood,
Assuming that the OU you listed is intended strictly as the location for all
your server objects, the following should accomplish what you are looking
for:

Const ADS_SCOPE_ONELEVEL = 1

Set oConn = CreateObject("ADODB.Connection")
Set oCommand = CreateObject("ADODB.Command")
oConn.Provider = "ADsDSOObject"
oConn.Open "Active Directory Provider"
Set oCommand.ActiveConnection = oConn

oCommand.Properties("Page Size") = 1000
oCommand.Properties("Searchscope") = ADS_SCOPE_ONELEVEL

sOU = "'LDAP://ou=Servers,dc=contoso,dc=com'"

oCommand.CommandText = "SELECT Name, ADsPath FROM " & sOU & _
" WHERE objectCategory ='computer'"
Set oRecordSet = oCommand.Execute
oRecordSet.MoveFirst
Do Until oRecordSet.EOF
WScript.Echo "List of member of local Administrators group for " &
oRecordSet.Fields("Name").Value
Set oLocalAdmins = GetObject("WinNT://" & oRecordSet.Fields("Name").Value &
"/Administrators")
For Each oLocalAdmin in oLocalAdmins.Members
WScript.Echo oLocalAdmin.Name
Next
oRecordSet.MoveNext
Loop

hth
Marcin


Similar ThreadsPosted
Ability to list groups member of a trusted domain is in July 26, 2006, 12:30 pm
Is local system account member of local Administrators group? June 21, 2005, 11:33 am
Allow user to install local printer without print operators member August 10, 2006, 11:44 am
Automatic certificate enrollment for local system failed after upgrading member server to domain controller August 25, 2005, 6:11 pm
Lost local admin password October 4, 2005, 8:17 pm
local admin group change, how? November 2, 2005, 10:53 am
Domain Users to have Local Admin rights April 28, 2006, 3:17 pm
Best practices for local admin account on servers? June 2, 2006, 1:46 pm
Changing local admin password on a set of machine in an ad network ? June 6, 2005, 1:28 pm
Deny Right to Local Admin Group to Log On Via Terminal Services? May 24, 2007, 12:28 pm

Our other projects:

Art Dolls, Fairies and Mermaids - Sunnyfaces.net

Roy's Linux, Programming and Search Engines messages

1-Script XML SitemapXML Sitemap