I would like to query an OU for objects and create security groups.
OU=Printers
The objects are printers that are published in AD. I would like to create two groups for each printer, one for default printer, one for additional printer.
Printer object names: MRH-01-q-mis
Group names to be created:
DefPrinter_mrh-01_q-mis
AddlPrinter_mrh-01_q-mis
I found a CreateADGroup by Howard, but am unsure of how to query the Printers OU and enumerate the objects and create a script that I can use with CreateADGroup to add the groups for the printers.
I used this syntax to obtain computer group membership for the purpose of adding printers based upon group membership. I'd like to now create the groups for the corresponding printers, checking for the existence of each group BEFORE creating them.
code:
$WS = GetObject("WinNT://" + @domain + "/" + @wksta + "$$")
if @error
? @serror
else
for each $grp In $WS.Groups
$GrpName = $grp.Name
if left($GrpName,11) = "DefPrinter_"
$defprinter = substr($GrpName,12)
$defprinter = join(split($defprinter,"_"),"\")
No idea what I'm doing, but going to start here:
code:
$logfile=c:\printers.xls
$printers = GetObject("LDAP://CN=Printers,DC=test,DC=local)
if @error
?@serror
else
$rc=redirectoutput($logfile,1)
for each $printer in $printers
$printername = $printer.name
$printername = substr ($printername,4)
? $printername ; to see results for now
if left($printername,7) = "MRH-01-"
$printgroup = substr($printerpName,8)
; create groups with createadgroup.udf
; work to do on this
next
$rc=redirectoutput('')
endif
Any direction is appreciated.
tjcarst
[ 14. October 2003, 19:42: Message edited by: tjcarst ]