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