/build/static/layout/Breadcrumb_cap_w.png

Help modifying vbscript to list all group members in AD

Hi.

I'm trying to build a script to basically list all objects (users AND computers) in all groups.

Here's what I have. It lists all users and and all the groups each user is in:

ServerName="OurDomain"

Set objXL = WScript.CreateObject("Excel.Application")
objXL.Visible = TRUE
objXL.WorkBooks.Add

objLine = 1
objXL.Cells(objLine, 1).Value = "Users"
objXL.Cells(objLine, 2).Value = "Groups"

objLine = objLine + 1
objXL.Cells(objLine, 1).Value = ServerName

Set Domain = GetObject("WinNT://" & ServerName)
For each Object in Domain
if Object.class = "User" then
set oUser = GetObject("WinNT://" & ServerName & "/" & Object.Name)
if oUser.accountdisabled = "False" then
for each oGroup in oUser.Groups
objLine=objLine+1
objXL.Cells(objLine,1).Value = Object.Name
objXL.Cells(objLine,3).Value = oGroup.Name
next
end if
end if
Next

msgbox "Done"

Really all I need to know is how to change this to grab computers rather than users:

if Object.class = "User" then
set oUser = GetObject("WinNT://" & ServerName & "/" & Object.Name)

0 Comments   [ + ] Show comments

Answers (4)

Posted by: brenthunter2005 19 years ago
Fifth Degree Brown Belt
0
Heres a little hint:

computername$

[;)]
Posted by: Bladerun 19 years ago
Green Belt
0
I'm not sure how to use the $

I did some reading on computername, and can get a list of the computers, but I'm not getting all the groups that computer is in.
Posted by: brenthunter2005 19 years ago
Fifth Degree Brown Belt
0
I have a faint memory that if using the WinNT provider (when you have Active Directory) Universal groups will got be returned.

You must connect using the LDAP provider, and query that way.

I'm not 100% sure sorry, you may want to check out the micro$oft newsgroups...
Posted by: Bladerun 19 years ago
Green Belt
0
Thanks anyway.

The frustrating thing is that I had this script built before & deleted it by mistake [:@]
Rating comments in this legacy AppDeploy message board thread won't reorder them,
so that the conversation will remain readable.
 
This website uses cookies. By continuing to use this site and/or clicking the "Accept" button you are providing consent Quest Software and its affiliates do NOT sell the Personal Data you provide to us either when you register on our websites or when you do business with us. For more information about our Privacy Policy and our data protection efforts, please visit GDPR-HQ