The only suggestion I can offer is to add additional debugging code into the CreateADGroups udf.

Add Cerror() udf to your script.

Output the variables values enclosed in quotes or other delimiter so that you can see where the value starts and stops. This is incase you have spaces or other characters that would be not seen.

Output the values and results for each ADSI call, get, put, and setinfo line.

Please give some more info regarding your test where if you supply the text name the function works and in the script the function fails. This would lead me to belive that you are passing the function invalid data even though it may look correct.
_________________________
Home page: http://www.kixhelp.com/hb/