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)
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:
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:
set oUser = GetObject("WinNT://" & ServerName & "/" & Object.Name)
0 Comments
[ + ] Show comments
Answers (4)
Please log in to answer
Posted by:
Bladerun
19 years ago
Posted by:
brenthunter2005
19 years ago
Posted by:
Bladerun
19 years ago
Rating comments in this legacy AppDeploy message board thread won't reorder them,
so that the conversation will remain readable.
so that the conversation will remain readable.