Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Add users & groups from A.D. to a local group via excel sheet 1

Status
Not open for further replies.

arilvade

IS-IT--Management
Mar 17, 2005
32
US
This script works with one group per user; how can I add more groups to each user? (some users have more groups than others)

Set objExcel = CreateObject("Excel.Application")
Set objWorkbook = objExcel.Workbooks.Open _
("C:\Scripts\New_users.xls")
intRow = 2
Do Until objExcel.Cells(intRow,1).Value = ""
strComputer = "dellcat01"
Set objGroup = GetObject("WinNT://" & strComputer & objExcel.Cells(intRow, 2).Value)
Set objUser = GetObject("WinNT://" & objExcel.Cells(intRow, 1).Value)
objGroup.Add(objUser.ADsPath)

intRow = intRow + 1
Loop
objExcel.Quit
 
Have you tried something like this in New_users.xls ?[tt]
A B
1 User Group
2 name1 group1
3 name1 group2
4 name2 group1
...[/tt]

Hope This Helps, PH.
FAQ219-2884
FAQ181-2886
 
Yes that would work, but I would like the excel sheet to be more efficient, something like this:

User group1 group2 group3 Etc.
jdoe admin d333 e444
gdoe admin a444 b444

I have allot of groups (approx. 15) for some users.
 
More like this ?
Set objExcel = CreateObject("Excel.Application")
Set objWorkbook = objExcel.Workbooks.Open("C:\Scripts\New_users.xls")
intRow = 2
Do Until objExcel.Cells(intRow,1).Value = ""
Set objUser = GetObject("WinNT://" & objExcel.Cells(intRow, 1).Value)
inCol = 2
Do Until objExcel.Cells(intRow,intCol).Value = ""
Set objGroup = GetObject("WinNT://dellcat01" & objExcel.Cells(intRow, intCol).Value)
objGroup.Add(objUser.ADsPath)
intCol = intCol + 1
Loop
intRow = intRow + 1
Loop
objExcel.Quit

Hope This Helps, PH.
FAQ219-2884
FAQ181-2886
 
I receive an error:
Line: 7
Char: 3
Error: Unknown runtime error

My excel sheet looks like this:
Name Group1 Group2 Group3 Etc.
John /users /guests /admin Etc.

 
Sorry for the typo :~/
Replace this:
inCol = 2
with this:
intCol = 2

Hope This Helps, PH.
FAQ219-2884
FAQ181-2886
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top