I also just noticed that the "function GroupAdd($Target, $Group, $ObjToAdd)" line was REM'd out in your posted code too, which could cause some issues. I would try something like the below code, if you're able to use atleast the 4.22 version of Kix, which I believe is when AScan was introduced.
Code:
BREAK ON
$ou = GetObject("LDAP://cn=Users,dc=domain,dc=local")
Dim $Filter[0]
$Filter[0] = "user"
$ou.Filter = $Filter
for each $account in $ou
$name = $account.name
? "name = $name"
$groups = $account.groups
If AScan ($groups, "Internet Mail Access") < 0
GroupAdd($account,"Internet Mail Denied", $account)
Endif
next
function GroupAdd($Target, $Group, $ObjToAdd)
;NAME GroupAdd
;
;ACTION Add's a object (user or group) to a group (global or local)
;
;SYNTAX GroupAdd(Target, Group, Object to add)
;
;PARAMETERS Target
; The Domain name or Workstation to work with. For faster workstation
; execution, include the Domain Name that the workstation is a meber of.
;
; "Kixtart/beanbag" would be working with the workstation Beanbag in the
; Kixtart domain
;
; Group
; The Group you want to add to
;
; Object to add
; This can be a local group or a userid, depending on what type of group
; the Group variable is. Always try to give the full name of the object.
;
;
;RETURNS @error code
;
;REMARKS ADSI com object must be installed.
;
;EXAMPLES ;this adds the domain user "testuser" to the global group "Domain Admins"
; $nul = groupadd("kixtart","Domain admins","testuser")
;
; ;this adds the user "testuser" in the domain "kixtart" to the local administrators
; ;group on the workstation beanbag
; $nul = Groupadd("kixtart/beanbag", "administrators", "kixtart\testuser")
DIM $target, $group, $OBJToAdd
DIM $obj, $objhome
if substr($target,1,2) = "\\"
$target = substr($target,3,len($target))
endif
If instr($objtoadd,"\") <> 0
$objtoadd = split($objtoadd,"\")
if ubound($objtoadd) <> 1
exit(13)
endif
$objhome = $objtoadd[0]
$obj = $objtoadd[1]
ELSE
$objhome = $target
$obj = $objtoadd
endif
$group = GetObject("WinNT://$target/$group")
if vartype($group) = 9 and @error = 0
$group.Add ("WinNT://$objhome/$obj")
else
$GroupAdd = @error
exit(@error)
endif
$GroupAdd = @error
exit(@error)
endfunction