#148102 - 2005-09-20 09:43 PM
Auto creating printers using AD groups
|
Duke999
Fresh Scripter
Registered: 2005-09-20
Posts: 13
|
Hello All, Forgive me for being a kix numskull, I've only just started looking at it for auto creating outlook profiles(excellent) and printers etc. I have created AD distribution lists, added users into them and want to auto create printers for the dist group. I have tried this bit of code but can not seem to get it to work properly. I am using the latest Kix version 4.5 and call it from a batch file kix.exe kixscript.kix
; Set Printers If fnInGroupAD("Sharp Printer") AddPrinterConnection ("\\servername\SHARP AR-407 PCL6") = 0 ? "Added printer connection...." EndIf If fnIngroupAD("Cardvat 1200 Printer") AddPrinterConnection ("\\servername\HP LaserJet 1200 Series PCL 6") SetDefaultPrinter ("\\servername\HP LaserJet 1200 Series PCL 6") ? "Added printer connection...." Endif if @userid = user SetDefaultPrinter ("\\servername\SHARP AR-407 PCL6") Endif
|
|
Top
|
|
|
|
#148104 - 2005-09-20 10:00 PM
Re: Auto creating printers using AD groups
|
Duke999
Fresh Scripter
Registered: 2005-09-20
Posts: 13
|
Thanks for the prompt reply Les, So if I create a security group instead could I just use IF InGroup instead?, then I would not need a UDF?, what is a UDF anyway? Thanks Mark
|
|
Top
|
|
|
|
#148107 - 2005-09-20 10:19 PM
Re: Auto creating printers using AD groups
|
Duke999
Fresh Scripter
Registered: 2005-09-20
Posts: 13
|
Cheers NTDOC, I'm using the latest KIX32.exe (4.5). All i'm trying to do is auto create printers for citrix clients running roaming profiles. I'm just looking for a quick simple script that created the printers for the users in the group. If I change the group for a dist to a security do I use the following?
If InGroup("domain\printergroup") 'User Found' ? AddPrinterConnection ("\\servername\SHARP AR-407 PCL6") = 0 ? "Added printer connection...." Else 'User not found' ? EndIf
Thanks Mark
|
|
Top
|
|
|
|
#148109 - 2005-09-20 10:51 PM
Re: Auto creating printers using AD groups
|
Duke999
Fresh Scripter
Registered: 2005-09-20
Posts: 13
|
Cheers Chaps, You are indeed the script guru's Will give it a go tomorrow and see. Reward yourself with a nice cold Kronkin Bonkin (Kreonenburg 1664). Battery going on the laptop so off to the pub.
|
|
Top
|
|
|
|
#148114 - 2005-09-21 04:29 PM
Re: Auto creating printers using AD groups
|
Chris S.
MM club member
   
Registered: 2002-03-18
Posts: 2368
Loc: Earth
|
Ah, well you got me. I fell for the trap and assumed he got it from here.
|
|
Top
|
|
|
|
#148116 - 2005-09-21 11:37 PM
Re: Auto creating printers using AD groups
|
Duke999
Fresh Scripter
Registered: 2005-09-20
Posts: 13
|
Chaps, I changed the script to use InGroup and all works fine with a security group. Thanks for the help. I've looked at the UDF from your forum, looks far more complicated then just using the InGroup statement. what would be the advantage to using this instead?. How would I use this to autocreate say PrinterA to AD security group ADPrint1
Function fnInGroupAD(ADPrint1) Dim $objSys,$objTarget,$aMemberOf,$sMemberOf $objSys = CreateObject("ADSystemInfo") $objTarget = GetObject("LDAP://"+Iif($bComputer,$objSys.ComputerName,$objSys.UserName)) $aMemberOf = $objTarget.GetEx("memberOf") For Each $sMemberOf in $aMemberOf If InStr($sMemberOf,"CN="+$sGroup+",") $fnInGroupAD = Not 0 Exit EndIf Next $fnInGroupAD = NOT 1 AddPrinterConnection ("\\servername\PrinterA") = 0 EndFunction
|
|
Top
|
|
|
|
#148117 - 2005-09-22 12:16 AM
Re: Auto creating printers using AD groups
|
Chris S.
MM club member
   
Registered: 2002-03-18
Posts: 2368
Loc: Earth
|
Doc, didn't I say that he should use security groups? I just made mention of the fact that fnInGroupAD() works with groups that InGroup() cannot handle (e.g. Universal Groups, Distribution Groups).
Duke, I don't think you've grasped how to use UDF's yet. There is no need to change the UDF at all, you include it in your script and then use it the same as a command or function that is native to KiX.
You should really review the FAQ: How to use UDFs
|
|
Top
|
|
|
|
Moderator: Glenn Barnas, NTDOC, Arend_, Jochen, Radimus, Allen, ShaneEP, Ruud van Velsen, Mart
|
0 registered
and 2220 anonymous users online.
|
|
|