Page 1 of 1 1
Topic Options
#78560 - 2001-11-07 09:17 PM More with ADSI
Anonymous
Unregistered


What's up guys, it's been a while since I've posted so I figured I'd ring in with my first small 2k1 script. It uses ADSI to enumerate all of the users in a specified global group and move them onto a new logon script.

code:

;********** UPMC Desktop **********
; Author: Randy Watson
; Date: 11/06/2001
; File: changelogonscript.kix
; Description: Script to change the logon script for users using ADSI
; Ver: 1.0
; Revision Date: N/A

Break On

Function Main()
? "Enumerating Group"
$Server = "WinNT"
$Domain = "1upmc-acct"
$Group = "Epic Admin"
$NewLogonScript = "modlogon2.bat"

$Users = EnumerateGroup($Server, $Domain, $Group)
For $i = 0 To UBound($Users) - 1
? "Changing primary logon script for " + $Users[$i]
$User = $Users[$i]
$User = GetObject("$Server://$Domain/$User")
$User.LoginScript = "$NewLogonScript"

;If you comment out the following setinfo line, changes will be discarded to user account
$User.SetInfo
Next
$User = 0
EndFunction


Function EnumerateGroup($Server, $Domain, $Group)
;Returns an array of users in specified group object
;Last member at Ubound(EnumerateGroup) - 1

Dim $Users[0]

$UserCounter = 0
$Group = GetObject("$Server://$Domain/$Group,Group")
For Each $Member In $Group.Members
ReDim Preserve $Users[$UserCounter + 1]
$Users[$UserCounter] = $Member.Name
$UserCounter = $UserCounter + 1
Next
$EnumerateGroup = $Users
$Group = 0
$Member = 0
EndFunction

Main

Exit



Top
#78561 - 2002-04-17 08:45 PM Re: More with ADSI
Will Hetrick Offline
Hey THIS is FUN

Registered: 2001-10-02
Posts: 320
Loc: Harrisburg, PA USA
Thanks Aerathi,
This is just what I was looking for. I did not want to go through 100,000 names on our login domain when only about 3000 of them was ours. The group check worked perfectly to seperate our people.
_________________________
You have at least 2 choices. Each choice changes your destiny. Choose wisely!

Top
#78562 - 2002-04-17 09:15 PM Re: More with ADSI
Les Offline
KiX Master
*****

Registered: 2001-06-11
Posts: 12734
Loc: fortfrances.on.ca
Nice of you to share your script, but (there's always a but) I don't think the Beta forum is the place for it. You should consider posting it in the UDF Library.
_________________________
Give a man a fish and he will be back for more. Slap him with a fish and he will go away forever.

Top
Page 1 of 1 1


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

Who's Online
1 registered (Allen) and 271 anonymous users online.
Newest Members
Sir_Barrington, batdk82, StuTheCoder, M_Moore, BeeEm
17886 Registered Users

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