|
|
|||||||
Hi there can any help, I'm trying to add a newly created user to a domain group can anyone give me an example. list below is the code i'm useing to create the account. Code: Function CreateAccount($UserName, $FullName, $ADsPath) $OU = GetObject($ADsPath) $UserObj = $OU.Create("User", "cn=" + $FullName) $UserObj.Put("sAMAccountName", $UserName) $UserObj.Put("givenName", $fname) ;First Name $UserObj.Put("sn", $sname) ;Last Name(Surname) $UserObj.Put("displayName", $accountname) $UserObj.Put("description", $fname + " " + $sname) ;Description $UserObj.Put("mail", "$accountname@@server.co.uk") ;E-mail $UserObj.Put("wWWHomePage", "www.server.co.uk") ;Web page $UserObj.Put("userPrincipalName", "$accountname@@student.server.co.uk") ;userPrincipalName $UserObj.Put("scriptPath", "student.exe") ;Logon Script $UserObj.Put("department", $group) $UserObj.Put("title", $accountname) $UserObj.Put("homeDrive", "H:") $UserObj.Put("homeDirectory", "\\student.server.co.uk\home\" + $accountname) $userObj.SetPassword($accountname) ;Sets the password to "newpassword" $userObj.Put("pwdLastSet", 0) ;User has to change the pw as soon as he/she logs in $userObj.AccountDisabled = 0 ;Enables the account $UserObj.SetInfo ; Objects cleanup $UserObj = 0 $OU = 0 EndFunction $accountname = "studenttest" $group = "studenttest" $fname = "studenttest" $sname = "studenttest" $username = "studenttest" $fullnamename = "studenttest" CreateAccount("$accountname", "$accountname", "LDAP://student.server.co.uk/OU=Standard Policy,DC=student,DC=server,DC=co,DC=uk") Thnaks in advance Glyn |
||||||||
|
|
|||||||
There are a few threads on the subject if you search around, try this one (and the referenced links) as a start: http://www.kixtart.org/forums/ubbthreads.php?ubb=showflat&Board=8&Number=188283 You can also use the command line "NET GROUP" to manipulate groups. |
||||||||
|
|
|||||||
Originally Posted By: Richard H. There are a few threads on the subject if you search around, try this one (and the referenced links) as a start: http://www.kixtart.org/forums/ubbthreads.php?ubb=showflat&Board=8&Number=188283 You can also use the command line "NET GROUP" to manipulate groups. Hi Richard H. After alot of mucking around managed to get it working. So a big thanks for pointing me into the right direction. Thanks Glyn |