|
| |||||||||
| Tags: active directory, ads groups, scripts |
![]() |
| | Thread Tools | Search this Thread |
|
#1
| |||
| |||
| Script to add existing AD users to a group
I am working in a environment with 4500 AD users. we have 2K3 and 2K8 DCs. I would like to craete two groups, one comprising 1500 users and the other with 1900 users. The users are currently existing in AD but I have to assign them to these new groups. I kindly request for a script that will assist me populate these groups with users. I have the lists of the users in two separate excel lists. Kindly assist |
|
#2
| |||
| |||
| Re: Script to add existing AD users to a group "tnai9" <tnai9.43lnjb@DoNotSpam.com> wrote in message news:tnai9.43lnjb@DoNotSpam.com... > > I am working in a environment with 4500 AD users. > we have 2K3 and 2K8 DCs. I would like to craete two groups, one > comprising 1500 users and the other with 1900 users. The users are > currently existing in AD but I have to assign them to these new groups. > I kindly request for a script that will assist me populate these groups > with users. > I have the lists of the users in two separate excel lists. > Kindly assist > > > -- > tnai9 > ------------------------------------------------------------------------ > tnai9's Profile: http://forums.techarena.in/members/51685.htm > View this thread: Script to add existing AD users to a group > > http://forums.techarena.in > What name format is in the Excel spreadsheets? Is it the Distinguished Names of the users or the "pre-Windows 2000 logon" names? -- Richard Mueller MVP Directory Services Hilltop Lab - http://www.rlmueller.net -- |
|
#3
| |||
| |||
| Re: Script to add existing AD users to a group
You are going to have to write a script using vbscript, powershell, perl, etc... There are scripts on the internet that you can probably work to snap this together. I have included some good starting points to assist you. Add users to a group http://gallery.technet.microsoft.com...b-6b3c9f59aab9 http://gallery.technet.microsoft.com...a-c12089f7cce7 Richard Meuller has a script to read a csv file, which you could export from your excel spreadsheet http://www.rlmueller.net/ReadCSV.htm -- Paul Bergson MVP - Directory Services MCTS, MCT, MCSE, MCSA, Security+, BS CSci 2008, 2003, 2000 (Early Achiever), NT4 Microsoft's Thrive IT Pro of the Month - June 2009 http://www.pbbergs.com Please no e-mails, any questions should be posted in the NewsGroup This posting is provided "AS IS" with no warranties, and confers no rights. "tnai9" <tnai9.43lnjb@DoNotSpam.com> wrote in message news:tnai9.43lnjb@DoNotSpam.com... > > I am working in a environment with 4500 AD users. > we have 2K3 and 2K8 DCs. I would like to craete two groups, one > comprising 1500 users and the other with 1900 users. The users are > currently existing in AD but I have to assign them to these new groups. > I kindly request for a script that will assist me populate these groups > with users. > I have the lists of the users in two separate excel lists. > Kindly assist > > > -- > tnai9 > ------------------------------------------------------------------------ > tnai9's Profile: http://forums.techarena.in/members/51685.htm > View this thread: Script to add existing AD users to a group > > http://forums.techarena.in > |
|
#4
| |||
| |||
| Re: Script to add existing AD users to a group "Richard Mueller [MVP]" <rlmueller-nospam@ameritech.nospam.net> wrote in message news:OZK93nxgKHA.2104@TK2MSFTNGP05.phx.gbl... > > "tnai9" <tnai9.43lnjb@DoNotSpam.com> wrote in message > news:tnai9.43lnjb@DoNotSpam.com... >> >> I am working in a environment with 4500 AD users. >> we have 2K3 and 2K8 DCs. I would like to craete two groups, one >> comprising 1500 users and the other with 1900 users. The users are >> currently existing in AD but I have to assign them to these new groups. >> I kindly request for a script that will assist me populate these groups >> with users. >> I have the lists of the users in two separate excel lists. >> Kindly assist >> >> >> -- >> tnai9 >> ------------------------------------------------------------------------ >> tnai9's Profile: http://forums.techarena.in/members/51685.htm >> View this thread: Script to add existing AD users to a group >> >> http://forums.techarena.in >> > > What name format is in the Excel spreadsheets? Is it the Distinguished > Names of the users or the "pre-Windows 2000 logon" names? > > -- > Richard Mueller > MVP Directory Services > Hilltop Lab - http://www.rlmueller.net > -- > I have two example VBScript programs that read user names from a spreadsheet, then do something. In this case, the program also reads a profilePath from the spreadsheet and updates the user object. This could be modified for your purpose. The first program reads user Distinguished Names (DN's) from the first column of the spreadsheet: http://www.rlmueller.net/UpdateUserProfile.htm The second program is identical, except the names read from the spreadsheet are "pre-Windows 2000 logon" names. This program uses the NameTranslate object to convert these name into Distinguished Names (DN's): http://www.rlmueller.net/UpdateUserProfile2.htm In either case, for your purpose there is no need to bind to the user object. You do need to bind to the group object (near the beginning of the script, not in the loop). You need to bind to the group with the full DN of the group. The loop (once you have strUserDN, the DN of the user) could be similar to below to add the user to the designated group (this is based on the second program): ============= Set objGroup = GetObject("LDAP://cn=MyGroup,ou=West,dc=MyDomain,dc=com") intRow = 2 Do While objSheet.Cells(intRow, 1).Value <> "" strUserNTName = Trim(objSheet.Cells(intRow, 1).Value) ' Use NameTranslate to convert NT name to Distinguished Name. On Error Resume Next objTrans.Set ADS_NAME_TYPE_NT4, strNetBIOSDomain & "\" & strUserNTName If (Err.Number <> 0) Then On Error GoTo 0 Wscript.Echo "User " & strUserNTName _ & " not found in Active Directory" End If On Error GoTo 0 strUserDN = objTrans.Get(ADS_NAME_TYPE_1779) ' Escape any forward slash characters, "/", with the backslash ' escape character. All other characters that should be escaped are. strUserDN = Replace(strUserDN, "/", "\/") ' Check if user already a member of the group. If (objGroup.IsMember("LDAP://" & strUserDN) = False) Then ' Add the user to the group. objGroup.Add("LDAP://" & strUserDN) End If intRow = intRow + 1 Loop -- Richard Mueller MVP Directory Services Hilltop Lab - http://www.rlmueller.net -- |
|
#5
| |||
| |||
| Re: Script to add existing AD users to a group
Thank you all for you responses. I used the attached script to pull these names from AD into an xlsx(MS Excel 07 sheets) file and classified them into two files called SAPusers(1500 Members) and ICSusers(1928 Members) based on the systems they use. I would like to add them to two exchange distribution groups, AllICSUsers and AllSAPUsers. Last edited by tnai9 : 23-12-2009 at 11:23 AM. |
|
#6
| |||
| |||
| Re: Script to add existing AD users to a group
Dear all, I did not go so far with the script. I tried editing it, but without much headway. Luckily i bumped into a tool by the name of BulkADUsers from wisesoft which enabled me add the users quite fast. I appreciate so much for all your comments |
![]() |
|
| Thread Tools | Search this Thread |
| |
Similar Threads for: "Script to add existing AD users to a group" | ||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Script to add existing AD users to a group | tnai9 | Active Directory | 1 | 26-05-2011 12:34 AM |
| copying users form one group to a new group | Johan deheugden | Active Directory | 4 | 28-10-2009 06:05 PM |
| ADMT 3.0 Users Migration: Fix Users' Group Memberships stopped working | Jason | Windows Server Help | 11 | 05-12-2008 01:14 PM |
| script to add multple users to local admin group on servers | tdubb | Windows Server Help | 1 | 21-03-2008 06:16 AM |
| Add users to Group via Script - [WP] | WILDPACKET | Active Directory | 9 | 30-01-2008 12:30 AM |