Interesting. I used the first part of my original script to write the names of the printers to a file (c:\printers.txt). Each line contains the name of a printer.

contents of c:\printers.txt

q-115hall
q-123hall
q-130hall
q-210hall
q-220hall
(etc.)

code:
; Creates printers.txt

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

$logfile=c:\printers.txt
$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))
? $printername

endif

next

$rc=redirectoutput('')

endif

Then I created this script to read the file.

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

call @ScriptDir+'\CreateAdGroup.udf'
call @ScriptDir+'\Readfile.udf'

$filename="c:\printers1.txt"

for each $line in ReadFile($filename)

$x=$line

if CreateAdGroup($DN_of_OU, "D_mrh-01_"+ $x, "global", 1, "Default Printer")=1
? "Group D_mrh_01_" + $x + " successfully created"
else
? "CreateAdGroup D_mrh_01_" + $x + " Failed with Error: " + @error
endif

if CreateAdGroup($DN_of_OU, "A_mrh_01_"+ $x, "global", 1, "Additional Printer")=1
? "Group A_mrh_01_"+" $x + " successfully created"

else

? "CreateAdGroup A_mrh_01_"+ $x + " Failed with Error: " + @error

endif

next

endif

I get the same error message.

Results returned to screen:
Create ADGroup D_mrh_01_q-115hall Failed with Error: -2147352567
Create ADGroup D_mrh_01_q-123hall Failed with Error: -2147352567
Create ADGroup D_mrh_01_q-130hall Failed with Error: -2147352567
Create ADGroup D_mrh_01_q-210hall Failed with Error: -2147352567
Create ADGroup D_mrh_01_q-220hall Failed with Error: -2147352567

and continues on for each printer.

tjcarst [Confused]

[ 22. October 2003, 23:59: Message edited by: tjcarst ]