2003 AD, Native forest and Domain.
XP SP2 clients.

I need to script up a way of clearing all current members for an AD
Distribution Group and then adding back in all the members from a .txt or
.csv file.

The script needs to be able to be run by users that have permissions to the
AD group object.

Any ideas?

Re: clear current members of a distrib grp and add new members from a by Paul

Paul
Tue May 06 05:55:16 PDT 2008

## Clear the group ##

Set objGroup = GetObject
("LDAP://cn=GroupName,ou=SomeOU,dc=domainName,dc=com")

objGroup.PutEx ADS_PROPERTY_CLEAR, "member", 0

objGroup.SetInfo



## Add user to the group ##

Set objGroup = GetObject _

("LDAP://cn=GroupName,ou=SomeOU,dc=domainName,dc=com")

objGroup.PutEx ADS_PROPERTY_APPEND, "member", Array(DistinguishedName)

objGroup.SetInfo


This should all be available at:
http://www.microsoft.com/technet/scriptcenter/scripts/default.mspx?mfr=true

--
Paul Bergson
MVP - Directory Services
MCTS, MCT, MCSE, MCSA, Security+, BS CSci
2008, 2003, 2000 (Early Achiever), NT4

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.

"Phil" <Phil@discussions.microsoft.com> wrote in message
news:35EB0503-0310-48C8-8317-119080743636@microsoft.com...
> 2003 AD, Native forest and Domain.
> XP SP2 clients.
>
> I need to script up a way of clearing all current members for an AD
> Distribution Group and then adding back in all the members from a .txt or
> .csv file.
>
> The script needs to be able to be run by users that have permissions to
> the
> AD group object.
>
> Any ideas?
>
>



Re: clear current members of a distrib grp and add new members fro by Phil

Phil
Tue May 06 17:34:03 PDT 2008

Thanks Paul.

In the ## Add user to the group ## section, how do I get it to read the list
of users to be added to the group in from a .txt or .csv file etc.

Phil


"Paul Bergson [MVP-DS]" wrote:

> ## Clear the group ##
>
> Set objGroup = GetObject
> ("LDAP://cn=GroupName,ou=SomeOU,dc=domainName,dc=com")
>
> objGroup.PutEx ADS_PROPERTY_CLEAR, "member", 0
>
> objGroup.SetInfo
>
>
>
> ## Add user to the group ##
>
> Set objGroup = GetObject _
>
> ("LDAP://cn=GroupName,ou=SomeOU,dc=domainName,dc=com")
>
> objGroup.PutEx ADS_PROPERTY_APPEND, "member", Array(DistinguishedName)
>
> objGroup.SetInfo
>
>
> This should all be available at:
> http://www.microsoft.com/technet/scriptcenter/scripts/default.mspx?mfr=true
>
> --
> Paul Bergson
> MVP - Directory Services
> MCTS, MCT, MCSE, MCSA, Security+, BS CSci
> 2008, 2003, 2000 (Early Achiever), NT4
>
> 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.
>
> "Phil" <Phil@discussions.microsoft.com> wrote in message
> news:35EB0503-0310-48C8-8317-119080743636@microsoft.com...
> > 2003 AD, Native forest and Domain.
> > XP SP2 clients.
> >
> > I need to script up a way of clearing all current members for an AD
> > Distribution Group and then adding back in all the members from a .txt or
> > .csv file.
> >
> > The script needs to be able to be run by users that have permissions to
> > the
> > AD group object.
> >
> > Any ideas?
> >
> >
>
>
>

Re: clear current members of a distrib grp and add new members fro by Paul

Paul
Wed May 07 05:36:32 PDT 2008

If you go to the script center from the link I provided you should be able
to find examples on reading a text file.

--
Paul Bergson
MVP - Directory Services
MCTS, MCT, MCSE, MCSA, Security+, BS CSci
2008, 2003, 2000 (Early Achiever), NT4

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.

"Phil" <Phil@discussions.microsoft.com> wrote in message
news:337995B3-1701-4368-903F-1E28A5271DD2@microsoft.com...
> Thanks Paul.
>
> In the ## Add user to the group ## section, how do I get it to read the
> list
> of users to be added to the group in from a .txt or .csv file etc.
>
> Phil
>
>
> "Paul Bergson [MVP-DS]" wrote:
>
>> ## Clear the group ##
>>
>> Set objGroup = GetObject
>> ("LDAP://cn=GroupName,ou=SomeOU,dc=domainName,dc=com")
>>
>> objGroup.PutEx ADS_PROPERTY_CLEAR, "member", 0
>>
>> objGroup.SetInfo
>>
>>
>>
>> ## Add user to the group ##
>>
>> Set objGroup = GetObject _
>>
>> ("LDAP://cn=GroupName,ou=SomeOU,dc=domainName,dc=com")
>>
>> objGroup.PutEx ADS_PROPERTY_APPEND, "member", Array(DistinguishedName)
>>
>> objGroup.SetInfo
>>
>>
>> This should all be available at:
>> http://www.microsoft.com/technet/scriptcenter/scripts/default.mspx?mfr=true
>>
>> --
>> Paul Bergson
>> MVP - Directory Services
>> MCTS, MCT, MCSE, MCSA, Security+, BS CSci
>> 2008, 2003, 2000 (Early Achiever), NT4
>>
>> 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.
>>
>> "Phil" <Phil@discussions.microsoft.com> wrote in message
>> news:35EB0503-0310-48C8-8317-119080743636@microsoft.com...
>> > 2003 AD, Native forest and Domain.
>> > XP SP2 clients.
>> >
>> > I need to script up a way of clearing all current members for an AD
>> > Distribution Group and then adding back in all the members from a .txt
>> > or
>> > .csv file.
>> >
>> > The script needs to be able to be run by users that have permissions to
>> > the
>> > AD group object.
>> >
>> > Any ideas?
>> >
>> >
>>
>>
>>



Re: clear current members of a distrib grp and add new members from a by Jorge

Jorge
Tue May 20 11:50:50 PDT 2008

how about using a batch with ADFIND/ADMOD?

goto joeware.net for those tools

--

Cheers,
(HOPEFULLY THIS INFORMATION HELPS YOU!)

# Jorge de Almeida Pinto # MVP Identity & Access - Directory Services #

BLOG (WEB-BASED)--> http://blogs.dirteam.com/blogs/jorge/default.aspx
BLOG (RSS-FEEDS)--> http://blogs.dirteam.com/blogs/jorge/rss.aspx
------------------------------------------------------------------------------------------
* How to ask a question --> http://support.microsoft.com/?id=555375
------------------------------------------------------------------------------------------
* This posting is provided "AS IS" with no warranties and confers no rights!
* Always test ANY suggestion in a test environment before implementing!
------------------------------------------------------------------------------------------
#################################################
#################################################
------------------------------------------------------------------------------------------
"Phil" <Phil@discussions.microsoft.com> wrote in message
news:35EB0503-0310-48C8-8317-119080743636@microsoft.com...
> 2003 AD, Native forest and Domain.
> XP SP2 clients.
>
> I need to script up a way of clearing all current members for an AD
> Distribution Group and then adding back in all the members from a .txt or
> .csv file.
>
> The script needs to be able to be run by users that have permissions to
> the
> AD group object.
>
> Any ideas?
>
>