Page 1 of 1 1
Topic Options
#187446 - 2008-05-02 08:45 PM filtering out machine before adding the users to the printers
Tony Offline
Getting the hang of it

Registered: 2001-11-04
Posts: 55
Loc: LA
Hey,

I neeed help with the syntax for filtering out the machines before adding the printers.

We are deploying printers to users via Windows AD (GPO). I want to filter out 3 terminal servers that should not apply to the script (the rest of the machines are fine). I don' have the luxury to move my computer/user around in the OU (also we are deploying via User Object in that GPO).

For example,
 Code:
If manchine name <> terminal1, terminal2, terminal3, then do the following

  If @UserID = bob
     AddPrinterConnection("\\lnx1\Brother_8860")
     delPrinterConnection("\\lnx1\hp4000")
     SetDefaultPrinter("\\lnx1\Brother_8860")
  EndIf

  If @UserID = jdole
     delPrinterConnection("\\ps1\Brother_8860")
     AddPrinterConnection("\\lnx1\hp4000") 
     AddPrinterConnection("\\lnx1\Brother_8860")
     SetDefaultPrinter("\\lnx1\hp4000")
  EndIf

End if

TIA,
-tt


Edited by NTDOC (2008-05-02 09:42 PM)
Edit Reason: Added code tags and formatting

Top
#187447 - 2008-05-02 08:51 PM Re: filtering out machine before adding the users to the printers [Re: Tony]
Gargoyle Offline
MM club member
*****

Registered: 2004-03-09
Posts: 1597
Loc: Valley of the Sun (Arizona, US...
 Code:
$TSList = "Terminal1,"Terminal2","Terminal3"
If AScan($TSList,@WKSTA) >=0
  Do Stuff
EndIf
_________________________
Today is the tomorrow you worried about yesterday.

Top
#187453 - 2008-05-03 01:02 AM Re: filtering out machine before adding the users to the printers [Re: Gargoyle]
Tony Offline
Getting the hang of it

Registered: 2001-11-04
Posts: 55
Loc: LA

Thanks a lot.

I will try it and report back.

Tt

Top
#187470 - 2008-05-06 01:03 AM Re: filtering out machine before adding the users to the printers [Re: Gargoyle]
Tony Offline
Getting the hang of it

Registered: 2001-11-04
Posts: 55
Loc: LA
Gargoyle,

I tested and I think you misread my post. Shouldn't it be -1 since I don't want the servers listed on the array to run if users are logging in ?



$TSList = "Terminal1,"Terminal2","Terminal3"
If AScan($TSList,@WKSTA) >-1
Do Stuff
EndIf


TIA,
tt

Top
#187482 - 2008-05-06 04:55 AM Re: filtering out machine before adding the users to the printers [Re: Tony]
Gargoyle Offline
MM club member
*****

Registered: 2004-03-09
Posts: 1597
Loc: Valley of the Sun (Arizona, US...
Actually more of a fingers moving faster than the brain.

You are correct you want a negative return.

If AScan($TSList,@WKSTA) = -1
_________________________
Today is the tomorrow you worried about yesterday.

Top
#187491 - 2008-05-06 07:25 PM Re: filtering out machine before adding the users to the printers [Re: Gargoyle]
Tony Offline
Getting the hang of it

Registered: 2001-11-04
Posts: 55
Loc: LA
Thanks for your reply.

For something like this below, do I need any other syntax, such as @echo off, etc..? So far it works.

TIA,
tt
;***********************************************************
$TSList = "terminal1", "test3", "test1", "test2"

If AScan($TSList,@WKSTA) =-1

If @UserID = joeca
AddPrinterConnection("\\vmad2\lexmark")
AddPrinterConnection("\\vmad2\canon4")
delPrinterConnection("\\vmad2\hp4000")
SetDefaultPrinter("\\vmad2\canon4")
EndIf


If @userID = bob
;delprinterconnection("\\vmad2\canon4")
addprinterconnection("\\vmad2\canon4")
addprinterconnection("\\vmad2\hp7000")
setdefaultPrinter("\\vmad2\hp7000")



Endif


If @UserID = jdole
delPrinterConnection("\\ps1\Brother_8860")
AddPrinterConnection("\\lnx1\hp4000")
AddPrinterConnection("\\lnx1\Brother_8860")
SetDefaultPrinter("\\lnx1\hp4000")
EndIf



EndIf


Edited by Tony (2008-05-06 07:26 PM)

Top
#187492 - 2008-05-06 08:07 PM Re: filtering out machine before adding the users to the printers [Re: Tony]
Mart Moderator Offline
KiX Supporter
*****

Registered: 2002-03-27
Posts: 4673
Loc: The Netherlands
Nope. @echo off is batch scripting and won't work with kix.

I made some small modifications to your script.

 Code:
$TSList = "terminal1", "test3", "test1", "test2"

If ASCAN($TSList,@WKSTA) =-1
	Select
		Case @UserID = "joeca"
			$rc = AddPrinterConnection("\\vmad2\lexmark")
			$rc = AddPrinterConnection("\\vmad2\canon4")
			$rc = DelPrinterConnection("\\vmad2\hp4000")
			$rc = SetDefaultPrinter("\\vmad2\canon4")
		Case @userID = "bob"
			;$rc = delprinterconnection("\\vmad2\canon4")
			$rc = AddPrinterConnection("\\vmad2\canon4")
			$rc = AddPrinterConnection("\\vmad2\hp7000")
			$rc = SetDefaultPrinter("\\vmad2\hp7000")
		Case @UserID = "jdole"
			$rc = DelPrinterConnection("\\ps1\Brother_8860")
			$rc = AddPrinterConnection("\\lnx1\hp4000") 
			$rc = AddPrinterConnection("\\lnx1\Brother_8860")
			$rc = SetDefaultPrinter("\\lnx1\hp4000")
		EndSelect
EndIf


BTW: please use the code tags next time you post some code. The formatting gets preserved so it is much more readable.
_________________________
Mart

- Chuck Norris once sold ebay to ebay on ebay.

Top
#187516 - 2008-05-07 11:11 PM Re: filtering out machine before adding the users to the printers [Re: Mart]
Tony Offline
Getting the hang of it

Registered: 2001-11-04
Posts: 55
Loc: LA
Mart,

Thanks for the code. The one I posted is just to confused?

Thanks,
Tt

Top
Page 1 of 1 1


Moderator:  Jochen, Allen, Radimus, Glenn Barnas, ShaneEP, Ruud van Velsen, Arend_, Mart 
Hop to:
Shout Box

Who's Online
0 registered and 837 anonymous users online.
Newest Members
ManuvdWielNL, Sir_Barrington, batdk82, StuTheCoder, M_Moore
17887 Registered Users

Generated in 0.058 seconds in which 0.024 seconds were spent on a total of 13 queries. Zlib compression enabled.

Search the board with:
superb Board Search
or try with google:
Google
Web kixtart.org