After further testing, Kent's code is functioning using a variable ($user) as the username. I think the error occurs when attempting to split the single user name from the user list, which is created by net users /domain pipe to a text file.
The code to split the username from the list:
code:
 
break on
$nul=open(1,"c:\users.txt")
$line=readline(1)
while not @error
for each $user in split($line)
gosub calculate
next
loop
$line=readline(1)
exit