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

Comments

Please log in to comment

Rating comments in this legacy AppDeploy message board thread won't reorder them,
so that the conversation will remain readable.

Answers

0
Heres a little hint:

computername$

[;)]
Answered 06/21/2005 by: brenthunter2005
Fifth Degree Brown Belt

Please log in to comment
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.
Answered 06/21/2005 by: Bladerun
Green Belt

Please log in to comment
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...
Answered 06/22/2005 by: brenthunter2005
Fifth Degree Brown Belt

Please log in to comment
0
Thanks anyway.

The frustrating thing is that I had this script built before & deleted it by mistake [:@]
Answered 06/22/2005 by: Bladerun
Green Belt

Please log in to comment
Answer this question or Comment on this question for clarity