Page 1 of 1 1
Topic Options
#173916 - 2007-02-14 06:47 PM Ad ComputerGroup
cellnet Offline
Starting to like KiXtart

Registered: 2002-02-26
Posts: 115
Loc: Sweden
Hi

This script needs improvment

the function is called everytime, and there is a lot of printers.....

Count stops at 95 \:\)

 Code:
SETCONSOLE("HIDE")
;------ -----------------------

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

;------ Uppmappningar av skrivare för Anestesi/IVA-----------------------

if ComputerInGroup('1')=1
	ADDPRINTERCONNECTION ("\\printserver\printername")

endif

if ComputerInGroup('2')=1
	ADDPRINTERCONNECTION ("\\printserver\printername01")

endif

if ComputerInGroup('3')=1
	ADDPRINTERCONNECTION ("\\printserver\printername02")

endif

if ComputerInGroup('4')=1
	ADDPRINTERCONNECTION ("\\printserver\printername03")

endif

if ComputerInGroup('5')=1
	ADDPRINTERCONNECTION ("\\printserver\printername04")

endif
 



Any suggestions ?

br erik

Top
#173917 - 2007-02-14 07:45 PM Re: Ad ComputerGroup [Re: cellnet]
Benny69 Offline
Moderator
*****

Registered: 2003-10-29
Posts: 1036
Loc: Lincoln, Ne
Not sure I understand your question.
_________________________
Wait don't order yet,... get KiXforms Designer .NET 2.0 (Beta)
KiXforms Designer .NET 2.0 (Beta)

Top
#173919 - 2007-02-14 08:32 PM Re: Ad ComputerGroup [Re: Benny69]
cellnet Offline
Starting to like KiXtart

Registered: 2002-02-26
Posts: 115
Loc: Sweden
Ok sorry.

The question is if its possible to load the function in memory or similiar, so the computer knows its group membership, instead of asking the same question.

The goal is to make the script faster, and minimize AD lookup's.

br
erik

Top
#173922 - 2007-02-14 09:19 PM Re: Ad ComputerGroup [Re: cellnet]
Les Offline
KiX Master
*****

Registered: 2001-06-11
Posts: 12734
Loc: fortfrances.on.ca
When KiX preparses the script, it loads all functions it finds into memory so I don't understand what your expectations are.
_________________________
Give a man a fish and he will be back for more. Slap him with a fish and he will go away forever.

Top
#173924 - 2007-02-14 09:23 PM Re: Ad ComputerGroup [Re: Les]
eriqjaffe Offline
Hey THIS is FUN

Registered: 2004-06-24
Posts: 214
Loc: Arlington Heights, IL USA
If the computers are in only one group, you could do it as a case/select statement.
Top
#173926 - 2007-02-14 10:07 PM Re: Ad ComputerGroup [Re: Les]
cellnet Offline
Starting to like KiXtart

Registered: 2002-02-26
Posts: 115
Loc: Sweden
ok

Not sure about that.
During rebug mode, the script "hangs" for a few secunds, every time the
 Code:
 if $oGrp.IsMember("WinNT://" + $domain + "/"  + @wksta + "$$" )
		$ComputerInGroup=1
is processed

But if it the way it should be.

thanks for the replys

br erik

Top
#173927 - 2007-02-14 10:24 PM Re: Ad ComputerGroup [Re: cellnet]
Shawn Administrator Offline
Administrator
*****

Registered: 1999-08-13
Posts: 8611
Curious, try putting this at the start of your "processing":

$START = @TICKS

then put this after all your group checking is done:

? "Elapsed = " + (@TICKS - $START)

this will give you the total millsecs processing. Whats the time ? We can use this to benchmark any improvements.

Top
#173931 - 2007-02-15 04:45 AM Re: Ad ComputerGroup [Re: Shawn]
Sealeopard Offline
KiX Master
*****

Registered: 2001-04-25
Posts: 11165
Loc: Boston, MA, USA
A potential speed-up would be to perform just a single query against AD and retrieve all computer group memberships at once into an array. Then you can cycle through the array without incurring additional overhead from multiple AD queries
_________________________
There are two types of vessels, submarines and targets.

Top
#173936 - 2007-02-15 12:16 PM Re: Ad ComputerGroup [Re: Sealeopard]
cellnet Offline
Starting to like KiXtart

Registered: 2002-02-26
Posts: 115
Loc: Sweden
@eriqjaffe:
No the computer can be member in multiple groups

--

I will ad a "timer" to the script.

---

The array thing sounds interesting.

Any ideas how it should look like ?

\erik

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
1 registered (Allen) and 1334 anonymous users online.
Newest Members
Viginette, ManuvdWielNL, Sir_Barrington, batdk82, StuTheCoder
17888 Registered Users

Generated in 0.059 seconds in which 0.027 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