I think your loop logic needs a lil work. If I understand your code correctly (entirely possible that i dont)...

Code:

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



Would this not loop through and add the user to the Internet Mail Denied group every time it sees a group that is not equal to Internet Mail Access? So if the user is a member of say 10 groups...it is going to add the user to Internet Mail Denied 10 times?