Page 1 of 1 1
Topic Options
#155642 - 2006-01-19 04:18 PM Speed up ADSI Query?
tylan Offline
Starting to like KiXtart

Registered: 2005-11-17
Posts: 115
Loc: Johnstown, PA
How can I shorten this so that it doesn't need to run every boot. I currently have this in my GPO as a startup script for all my computers.

Code:
  
$pdcname = "SOMERSET-DC"
$computername = "%COMPUTERNAME%"

$userstring = "LocalAdmins"
$groupstring = "Administrators"
$groupobj = GetObject("WinNT://" + $computername + "/" + $groupstring)
$groupobj.add ("WinNT://" + $pdcname + "/" + $userstring)

$userstring = "LocalPowerUsers"
$groupstring = "Power Users"
$groupobj = GetObject("WinNT://" + $computername + "/" + $groupstring)
$groupobj.add ("WinNT://" + $pdcname + "/" + $userstring)

$userstring = "LocalRDPUsers"
$groupstring = "Remote Desktop Users"
$groupobj = GetObject("WinNT://" + $computername + "/" + $groupstring)
$groupobj.add ("WinNT://" + $pdcname + "/" + $userstring)




Thanks

Top
#155643 - 2006-01-19 04:20 PM Re: Speed up ADSI Query?
Radimus Moderator Offline
Moderator
*****

Registered: 2000-01-06
Posts: 5187
Loc: Tampa, FL
try to do an ingroup or a Groupmembers() first
_________________________
How to ask questions the smart way <-----------> Before you ask

Top
#155644 - 2006-01-19 04:24 PM Re: Speed up ADSI Query?
Les Offline
KiX Master
*****

Registered: 2001-06-11
Posts: 12734
Loc: fortfrances.on.ca
Well... InGroup() would cause round trips to the DC and GroupMembers() is probably just as intense as what he already has.
_________________________
Give a man a fish and he will be back for more. Slap him with a fish and he will go away forever.

Top
#155645 - 2006-01-19 04:36 PM Re: Speed up ADSI Query?
Radimus Moderator Offline
Moderator
*****

Registered: 2000-01-06
Posts: 5187
Loc: Tampa, FL
local groups... might not need to resolve
_________________________
How to ask questions the smart way <-----------> Before you ask

Top
#155646 - 2006-01-19 05:04 PM Re: Speed up ADSI Query?
tylan Offline
Starting to like KiXtart

Registered: 2005-11-17
Posts: 115
Loc: Johnstown, PA
So, just stick with what I have?
Top
#155647 - 2006-01-20 02:41 PM Re: Speed up ADSI Query?
Chris S. Offline
MM club member
*****

Registered: 2002-03-18
Posts: 2368
Loc: Earth
Question for you? What are LocalAdmins, LocalPowerUsers, and LocalRDPUsers? They look like group names to me.

If so, InGroup() isn't going to help you.

Top
#155648 - 2006-01-28 12:19 AM Re: Speed up ADSI Query?
Richie19Rich77 Offline
Seasoned Scripter
*****

Registered: 2002-08-16
Posts: 624
Loc: London, England
Why not just do this, it will only work if the GPO is run as a domain admin account.

Code:

$Array = "Administrators_LocalAdmins","Power Users_LocalPowerUser","Remote Desktop Users_LocalRDPUsers"

For Each $ArrayString in $Array
Shell 'Net Group '+Split($ArrayString,'_')[1]+' '+Split($ArrayString,'_')[0]+' /Add /Domain'
Next



Edited by Richie19Rich77 (2006-01-28 12:20 AM)

Top
#155649 - 2006-01-28 01:26 AM Re: Speed up ADSI Query?
Lonkero Administrator Offline
KiX Master Guru
*****

Registered: 2001-06-05
Posts: 22346
Loc: OK
wtf?
add domain?
heck no.

he is doing a simple localgroup add.
so, surely simple if not ingroup("\\"+@wksta+"\localgroup name") shell "net localgroup add" script is fine.
_________________________
!

download KiXnet

Top
#155650 - 2006-01-28 12:30 PM Re: Speed up ADSI Query?
Richie19Rich77 Offline
Seasoned Scripter
*****

Registered: 2002-08-16
Posts: 624
Loc: London, England
Sorry I forgot about the localgroup command, You wont be able to use Ingroup as he wants users added that are not the current user.

Haven't tested, and the script will keep trying to add users to localgroup no matter if they are already member.

Code:

$Array = "Administrators_LocalAdmins","Power Users_LocalPowerUser","Remote Desktop Users_LocalRDPUsers"

For Each $ArrayString in $Array
Shell 'Net Localgroup '+Split($ArrayString,'_')[1]+' '+Split($ArrayString,'_')[0]+' /Add'
Next



Edited by Richie19Rich77 (2006-01-29 01:18 AM)

Top
#155651 - 2006-01-28 09:26 PM Re: Speed up ADSI Query?
Lonkero Administrator Offline
KiX Master Guru
*****

Registered: 2001-06-05
Posts: 22346
Loc: OK
indeed, forgot that aspect of it.
hmm...

tylan, is that code of yours slow with adsi or why you asked for a speed up?
_________________________
!

download KiXnet

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 1179 anonymous users online.
Newest Members
batdk82, StuTheCoder, M_Moore, BeeEm, min_seow
17885 Registered Users

Generated in 0.053 seconds in which 0.013 seconds were spent on a total of 12 queries. Zlib compression enabled.

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