|
|
|||||||
I want to create a new group in my Active directory using the following script: $DomainName=EUROPE.fs.mydomain.com $ADsPath="LDAP://OU=Groups,OU=DE,DC=europe,DC=FS,DC=mydomain,DC=com" CreateGroup("GDEUTest","Testgruppe") Function CreateGroup($GRPName, $description) $OUObj = GetObject($ADsPath) $UserObj = $OU.Create("Group","cn=$GRPName") $UserObj.Put ("description", $description) $UserObj.Put ("sAMAccountName", $GRPName) $UserObj.SetInfo ; Objects cleanup $UserObj = 0 $OUObj = 0 EndFunction Whenever I run it I get this error: ERROR : expected ')'! which shall be in this line: $UserObj = $OU.Create("Group","cn=$GRPName") I cannot find the error. Can anyone help ? |
||||||||
|
|
|||||||
Change $UserObj = $OU.Create("Group","cn=$GRPName") to $UserObj = $OU.Create("Group","cn="+$GRPName) |
||||||||
|
|
|||||||
Already tried that. Unfortunately didn't help. |
||||||||
|
|
|||||||
$OU.Create should that not be $OUObj.Create(...), you do not have $OU defined |
||||||||
|
|
|||||||
Not sure if this helps but you have $GRPName enclosed in string. $UserObj = $OU.Create("Group", "cn=$GRPName") This may or may not be the problem |
||||||||
|
|
|||||||
Also try $OUObj = GetObject("LDAP://OU=Groups,OU=DE" + $DomainName) |
||||||||
|
|
|||||||
I have already done the heavy lifting for you. http://www.kixtart.org/ubbthreads/showflat.php?Cat=&Board=UBB12&Number=112366 |
||||||||
|
|
|||||||
Howard, you made my day. Not only that your script works great, it also showed me where my mistake was. After changing my script like this $OU = GetObject($ADsPath) $UserObj = $OU.Create("Group","cn=$GRPName") it works also. Thanks a lot for your help. |
||||||||
|
|
|||||||
Good to hear. You should however refrain from using vars in strings. |