I have seen some ADSI COM calls fail and the text line used inconjuction with a "+$user.loginscript" will cause a failure is the property is not defined.

So to get around that issue assign it to a variable first and check @error to see if you got it or not.

I have updated the script to use this method. See below.

code:
Break ON
; uncomment the next line to step through the code
; Debug ON
; Example of LDAP call. GetObject("LDAP://ou=Users,ou=YourBusinessUnit,dc=YourCompany,dc=com")
; You need to know your LDAP connection. You can maybe find it by checking the propery details on the OU for your users.
$target = GetObject("LDAP://OU=Test,OU=Information Systems,OU=AdminBldg,DC=sussexcounty,DC=net")
? 'Error = '+@ERROR+' - '+@SERROR
$loginscript="logon.bat"
For Each $user in $target
? 'checking user: '+$user.name
$script = $user.loginscript
? Logon swcript error: @error - @serror"
? 'assigned login script: '+$script
If $Script <> $loginscript
? "Current Script for " +$user.name " is: " +$script+ " Should be: " +$loginscript
$user.loginscript=$loginscript ; Remove the semi-colon at the front of this line to enable actually resetting the logon bat.
? 'Error = '+@ERROR+' - '+@SERROR
$user.SetInfo ; Remove the semi-colon at the front of this line to enable actually resetting the logon bat.
? 'Error = '+@ERROR+' - '+@SERROR
? "Changed current Script for " +$user.name " to: " +$user.loginscript
EndIf
Next
? 'If no user was displayed, then no user was retrieved from the OU'

_________________________
Home page: http://www.kixhelp.com/hb/