Try this instead...

Code:

$domain = GetObject("WinNT://"+@Domain)
$nul=RedirectOutput("domainusers.log")
For Each $object in $domain
If $object.class = "user"
? $object.name
Endif
Next



You were getting a 0 because you were not trapping the return code from the RedirectOutput function. Notice I added a $nul= to the front of it so that the return code of 0 is now sent to the $nul variable and not to the console. I also moved the RedirectOutput outside of the For Next loop since you only have to specify it once. You code was also returning groups as well as users so I added the .class If Endif portion to be sure it only logs users.