It is a function that I found here on the message boards
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
for each $group in $groups
$groupname = $group.name
?"groupname = $groupname"
if $groupname = "Internet Mail Access"
?"Internet Mail Access is enabled"
exit 0
else
GroupAdd($account,"Internet Mail Denied", $account)
?"No Internet Mail"
endif
next
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