View Single Post
Old 08-08-2007   #4 (permalink)
Karl Mitschke


 
 

Re: Add User to AD Group

"Thomas M." <NoEmailReplies@Please.com> wrote in message
news:%23mVZSkV2HHA.1124@TK2MSFTNGP06.phx.gbl...
> I'm new to PowerShell and I'm trying to create a script that will add a
> user to an Active Directory group. I copied the following code out of a
> book into PrimalScript 4.1 Enterprise and modified it for my environment.
> I've sanitized the code (force of habit when posting on the Internet).
>
> xxxx = My division OU
> yyy = My agency OU
> zz = My state
>
> Dim objGroup
>
> set objGroup = GetObject _
>
> ("LDAP://CN=UserRightsExceptions,CN=Groups,CN=UserRightsTesting,CN=xxxx,CN=yyy,DC=state,DC=zz,DC=ads")
> objGroup.add _
>
> ("CN=CXLMTUSR,OU=LimitedUsers,OU=UserRightsTesting,OU=xxxx,OU=yyy,DC=state,DC=zz,DC=ads")
> objGroup.SetInfo
>
> So basically, I want to add the user named CXLMTUSR to the
> UserRightsExceptions group in Active Directory. I have confirmed that
> both distinguished names are correct, assuming no syntax errors. When I
> run the script I get the following error:
>
> <Path>\AddUserToGroup.vbs(3, 1) (null): There is no such object on the
> server.
> Exit code: 0 , 0000h
>
> where <Path> is the full path to the script file.
>
> Can someone show me what I am doing wrong?
>
> --Tom


Tom;

I'm in the same state, same division.

I just did this for a 130 user list, I can send some code if you'd like.

Karl


My System SpecsSystem Spec