|
|
|||||||
I am trying to script network printer installation based upon the physical location a user logs on from...currently I am using DHCP reservations and scripting according to IP address and what group the user account is part of. What I'm trying to accomplish through KIX is to group my computer accounts and script the network printer according to what group the comptuer account is in. Here's a snapshot of my KIX: if INSTR("$groups","Nurses;") AND INSTR("$ipadd","10.1.1.201") OR INSTR("$ipadd","10.1.1.202") OR INSTR("$ipadd","10.1.1.203") if ADDPRINTERCONNECTION ($pod1ptr) = 0 ? "Added printer connection...." endif endif Is it possible to script on computer account group membership? Thanks! Mike |
||||||||
|
|
|||||||
Yes. See ComputerInGroup.udf http://www.kixtart.org/board/ultimatebb.php?ubb=get_topic;f=12;t=000457 See also the last post in this thread for printers added based upon group membership http://www.kixtart.org/board/ultimatebb.php?ubb=get_topic;f=1;t=007920. I have this working based upon variables because I have so many printers. It would be easier to do if you had fewer printers and could use ComputerInGroup.udf. Let me know if you want any more info on this, I am a beginner, so the experts here are a better source of help than me. I tend to need everything spelled out for me. I also have one that works based upon a printsetup.ini file. All of my scripts have been obtained by code that exists here and tweaking done with the help of other here. [ 17. October 2003, 20:35: Message edited by: tjcarst ] |
||||||||
|
|
|||||||
Untested, but try this: code:tjcarstcall @scriptdir+'\computeringroup.udf' |
||||||||
|
|
|||||||
See also TCP/IP Primer, Part I - IP Addresses . |
||||||||
|
|
|||||||
Awesome! Thanks guys, I'll give that a try and I'll post results... |
||||||||
|
|
|||||||
Hi guys, I am just getting back to testing this and I think I need a hand with the syntax...I'm a newbie to KIX... I've tried putting the UDF in a seperate file and also incorporating it in the KIX script - I haven't had luck with either. I would prefer to have it in a seperate *.udf file... 1. So if I had this code in computeringroup.udf: Function ComputerInGroup($group,optional $Domain) Dim $oGrp if not $domain $domain=@domain endif $oGrp = GetObject("WinNT://" + $domain + "/" + $group + ",group" ) if @error exit 1 endif if $oGrp.IsMember("WinNT://" + $domain + "/" + @wksta + "$$" ) $ComputerInGroup=1 else $ComputerInGroup=0 endif endfunction 2. I called upon the .udf with this code in my KIX script: call @scriptdir+'\computeringroup.udf' if ComputerInGroup("$groups","Bruns Pod 1;") AND INSTR("$ipadd","10.1.1.") if ADDPRINTERCONNECTION ($ptrpod1) = 0 ? "Added printer connection...." endif endif 3. I have put the computer account in the group called "Bruns Pod 1". I know I'm missing syntax...could you help me out? Thanks a million! Mike |
||||||||
|
|
|||||||
See the FAQ Forum under How to use UDFs and TCP/IP Primer, Part I - IP Addresses . You should also check the ComputerInGroup() UDF header for correct syntax as I'm pretty sure yoru syntax is incorrect. Also, please don't use vars inside strings. |
||||||||
|
|
|||||||
I still haven't gotten this to work...I copied the syntax for the computeringroup.udf from here: http://www.kixtart.org/board/ultimatebb.php?ubb=get_topic;f=12;t=000457 I have 4 printers in 4 different locations that I want to map, so it's not really that complex...I basically have 4 pods, and depending on what pod users logon to I want them to receive that pod's printer...I must be close, but I'm getting tripped up on the syntax... I have the computeringroup.udf in my netlogon directory, but I'm not sure what to have in my main kix script for syntax...any help would be appreciated! Thanks, Mike |
||||||||
|
|
|||||||
Don't modify the ComputerInGroup.udf Since you only have 4 printers, it would be easiest to write the code for each printer. You may want to check to see if it is already mapped using PriMapState.udf and set it to default using SetDefaultPrinter. I know there is a way to use an array so you don't have to create the script for each printer, but will have to research this, as I, too am a new Kixtart user. Change your script to this: code:Edited to include proper syntax. Thanks Howard, missed that.$prtpod1="\\server\share1" tjcarst [ 21. October 2003, 21:44: Message edited by: tjcarst ] |
||||||||
|
|
|||||||
Read the TCP/IP Primer as the way you compare the IP Address will not work! UDFs are the way to go for IP address comparisons! |
||||||||
|
|
|||||||
Use proper quote syntax please: $prtpod1=\\server\share1 shouls be: $prtpod1="\\server\share1" |
||||||||
|
|
|||||||
Oh, and the binary logic used in your very first post is incorrect as you don't properly separate the AND and OR blocks from each other. At least the binary logic will not achieve what you try to do. |
||||||||
|
|
|||||||
Why are you even using the IP range if you are mapping based on groups? Put the pc's in the group and map on that condition. Do they move to different subnets and exist in different groups? tjcarst |
||||||||
|
|
|||||||
The IP address syntax could have location-based reasons as only the three specified computer should print to the particular printer and only if it is a nurse (and not a doctor). Might be a special-purpose printer. |
||||||||
|
|
|||||||
Using IsInSubnet.udf http://www.kixtart.org/cgi-bin/ultimatebb.cgi?ubb=get_topic;f=12;t=000053 Try this: code:Edited to add call to isinsubnet.udf$ip=@IPADDRESS0 tjcarst [ 21. October 2003, 23:36: Message edited by: tjcarst ] |
||||||||
|
|
|||||||
code:is incorrect, just use the IsInSubnet call directly. And please don't use vars in strings (or quotes)!isinipsubnet("$answer") [ 21. October 2003, 23:37: Message edited by: sealeopard ] |
||||||||
|
|
|||||||
http://www.kixtart.org/cgi-bin/ultimatebb.cgi?ubb=get_topic;f=12;t=000053 At first I did have isinipsubnet, but this links shows isinsubnet. I'll correct the syntax. Again. Sorry, I'm working on a million things and just thought I might be able to give Matt a little direction. It's apparent that I, too, am a newbie. |
||||||||
|
|
|||||||
Download BinaryIP.udf and try this http://www.kixtart.org/cgi-bin/ultimatebb.cgi?ubb=get_topic;f=12;t=000030 Are you using a normal class a (255.0.0.0)10.0.0.0 subnet as a class C (255.255.255.0) network - 10.1.1.0/255.255.255.0? code:call @ScriptDir+'\BinaryIP.udf' |
||||||||
|
|
|||||||
Now, what does the BinaryIP UDF have to do with the Subnet UDF as you don't include the Subnet UDF in your code? Also, why do you jump back and forth between different UDFs, anyway? One time you use IsInSubnet(), another time you use BinaryIP(0/Subnet(). They both accomplish the same. |
||||||||
|
|
|||||||
No idea. Just trying to get something to work for Mike. I don't know why I try though, I can't get anything to work for me. Edited to add that the link for subnet.udf says BinaryIP is a requirement. tjcarst [ 22. October 2003, 18:44: Message edited by: tjcarst ] |
||||||||
|
|
|||||||
Hi guys, I'm taking the IP address right out of the equation...I'm just going to create 4 groups, one for each pod... I'm going to try TJ's suggestion...I'll let you know the results.. :-) Thanks for all your help |
||||||||
|
|
|||||||
Ok, this is what I have for syntax in my kix file: $pod1ptr="\\server\Pod1" $pod2ptr="\\server\Pod2" $pod3ptr="\\server\POD3HPLJ" $pod4ptr="\\server\HPLJ2100POD4" call @scriptdir+'\computeringroup.udf' if ComputerInGroup(Pod1)=1 $nul=AddPrinterConnection(\\server\$pod1ptr) ? "Status - Added printer connection "$pod1ptr ? @serror $nul=SetDefaultPrinter($pod1ptr) ? "Status - Default printer set "$pod1ptr endif Here is the syntax I have in my computeringroup.udf... Function ComputerInGroup($group,optional $Domain) Dim $oGrp if not $domain $domain=@domain endif $oGrp = GetObject("WinNT://" + $domain + "/" + $group + ",group" ) if @error exit 1 endif if $oGrp.IsMember("WinNT://" + $domain + "/" + @wksta + "$$" ) $ComputerInGroup=1 else $ComputerInGroup=0 endif endfunction I am getting an error that says: error: invalid method/function call: missing ')'! line: 58 Any ideas? |
||||||||
|
|
|||||||
You're missing quotes all over the place! Please use proper quoting as explained in the KiXtart Manual. Strings MUST be enclosed within quotes and vars should not be used within quotes! |
||||||||
|
|
|||||||
Guys! I got it!! Here is the script: $pod1ptr="\\server\Pod1" $pod2ptr="\\server\Pod2" $pod3ptr="\\server\POD3HPLJ" $pod4ptr="\\server\HPLJ2100POD4" call @scriptdir+'\computeringroup.udf' if ComputerInGroup('Pod1')=1 $nul=AddPrinterConnection($pod1ptr) ? "Status - Added printer connection "$pod1ptr ? @serror $nul=SetDefaultPrinter($pod1ptr) ? "Status - Default printer set "$pod1ptr endif if ComputerInGroup('Pod2')=1 $nul=AddPrinterConnection($pod2ptr) ? "Status - Added printer connection "$pod2ptr ? @serror $nul=SetDefaultPrinter($pod2ptr) ? "Status - Default printer set "$pod2ptr endif if ComputerInGroup('Pod3')=1 $nul=AddPrinterConnection($pod3ptr) ? "Status - Added printer connection "$pod3ptr ? @serror $nul=SetDefaultPrinter($pod3ptr) ? "Status - Default printer set "$pod3ptr endif if ComputerInGroup('Pod4')=1 $nul=AddPrinterConnection($pod4ptr) ? "Status - Added printer connection "$pod4ptr ? @serror $nul=SetDefaultPrinter($pod4ptr) ? "Status - Default printer set "$pod4ptr endif Thanks for all your help, this is going to save me a ton of time! |
||||||||
|
|
|||||||
Congrats, Mike I'm happy you were able to get something to work for you!! tjcarst |
||||||||
|
|
|||||||
Also, if you did not want anything returned to the users, you could remove the lines that start with ? - this is informational only. tjcarst |
||||||||
|
|
|||||||
If the printer assignments are mutually exclusive, then a SELECT-CASE-ENDSELECT construct is more efficient. |