If I disable the portion that creates the groups, I can see that I am retrieving the printer names and generating the correct group name I want to create.

If I enable the portion that creates the groups, I get the error after every group:
A_mrh-01_q-therapy
CreateAdGroup Failed with Error: -2147352567
A-mrh-01_q-therapy2
CreateAdGroup Failed with Error: -2147352567

However, if I don't generate the group names using my script and just type into the script the name of the group I want to create, it is successfully created.

I don't think I am correctly passing the group names to CreateAdGroup in my script and am not clever enough to figure out what needs to be changed.

Thanks for any direction you can give.

tjcarst

code:
;http://www.kixtart.org/board/ultimatebb.php?ubb=get_topic;f=1;t=007920

call @ScriptDir+'\CreateAdGroup.udf'

;********** Beginning of group creation *********

$logfile=c:\printers.xls
$printers = GetObject("LDAP://OU=Printers,DC=madonna,DC=local")
$DN_of_OU ="OU=Printer Groups,DC=madonna,DC=local"

if @error
? @serror
else

$rc=redirectoutput($logfile,1)

for each $printer in $printers
$printername = $printer.name
$printername = substr($printername,4)

if left($printername,7) = "MRH-01-"
$printername = lcase(substr($printername,8))

$defprintgroup = "D_mrh-01_"+$printername
$addlprintgroup = "A_mrh-01_"+$printername

if CreateAdGroup($DN_of_OU, $defprintgroup, "global", 1, "Default Printer")
? "Group successfully created"
else
? "CreateAdGroup Failed with Error: " + @error
endif

if CreateAdGroup($DN_of_OU, $addlprintgroup, "global", 0, "Additional Printer")
? "Group successfully created"
else
? "CreateAdGroup Failed with Error: " + @error
endif

endif

next

$rc=redirectoutput('')

endif



[ 17. October 2003, 18:29: Message edited by: tjcarst ]