Here's a start to the function, if you want to test it out.
 Code:
Function ObjectsInOU(OPTIONAL $OU, OPTIONAL $filter)
   Dim $f[0],$objs[0],$x,$objADsPath,$obj
   If not $OU
      $OU = GetObject("LDAP://"+CreateObject("ADSystemInfo").ComputerName).Parent
      If @Error
         Exit @Error
      Endif
   Endif
   $objADsPath = GetObject($OU)
   If @Error = 0
      If $filter
         $f[0] = $filter
         $objAdsPath.filter = $f
      Endif
      $x = 0
      For Each $obj In $objAdsPath
         If $filter="user"
            If $obj.Class="User"
               $objs[$x] = Split($obj.Name,"=")[1]
               $x = 1+$x
               ReDim Preserve $objs[$x]
            Endif
         Else
            $objs[$x] = Split($obj.Name,"=")[1]
            $x = 1+$x
            ReDim Preserve $objs[$x]
         Endif
      Next
      If UBound($objs) > 0
         ReDim Preserve $objs[UBound($objs)-1]
      Endif
      $ObjectsInOU = $objs
   Else
      Exit @Error
   Endif
EndFunction

It would be called like so...
 Code:
$objects = ObjectsInOU("LDAP://OU=folder,...","Computer")

If @Error = 0
   For each $o in $objects
      ? $o
   Next
Else
   ? "Error: "+@Error
Endif


Edited by ShaneEP (2012-09-01 12:13 AM)