Ok, found a InOU() function at scriptlogic.
http://www.scriptlogic.com/kixtart/FunctionLibrary_ViewFunction.aspx?ID=InOU

The example below works but you can only check one OU. If a user is a member of the users OU in the Finance OU and an other user is a member of the Users OU in the Warehouse OU then it will both return 1 (is a member). Maybe it can be altered a bit to support sub OU's but I have time to figure out what to modify right now.

 Code:
Break on

$IsComputer = ""
$OUName = "Users"

$rc = InOU($OUName, $IsComputer)
? $rc
Sleep 5


Function InOU($OUName, Optional $IsComputer)    ; (Standalone version restricted to Windows 2000 and XP systems)
	Dim $OUelement
	    
	If Len($IsComputer) > 0
		$IsComputer = 1
	Else
		$IsComputer = 0
	EndIf
	    
	$InOU = 0
	    
	If Len($_InOUUser) > 0 And Len($_InOUComputer) > 0
		If $IsComputer = 0
			If $_InOUUser = "Initialized but no OU available"
				Return
			EndIf
			For Each $OUelement in Split($_InOUUser, ",")
				If $OUElement = $OUName $InOU = 1 EndIf
			Next
		Else
			If $_InOUComputer = "Initialized but no OU available"
				Return
			EndIf
			For Each $OUelement in Split($_InOUComputer, ",")
				If $OUElement = $OUName $InOU = 1 EndIf
			Next
		EndIf
	Else
		$sysinfo = CreateObject("adsysteminfo")
		If $sysinfo <> 0
			For Each $OUelement in Split($sysinfo.username, ",")
				If Left($OUelement, 3) = "OU="
					$_InOUUser = $_InOUUser + SubStr($OUelement, 4) + ","
					If $IsComputer = 0
						If SubStr($OUelement, 4) = $OUName $InOU = 1 EndIf
					EndIf
				EndIf
			Next
			If Len($_InOUUser) = 0
				$_InOUUser = "Initialized but no OU available"
			EndIf
			            
			For Each $OUelement in Split($sysinfo.computername, ",")
				If Left($OUelement, 3) = "OU="
					$_InOUComputer = $_InOUComputer + "," + SubStr($OUelement, 4)
					If $IsComputer = 1
						If SubStr($OUelement, 4) = $OUName $InOU = 1 EndIf
					EndIf
				EndIf
			Next
			If Len($_InOUComputer) = 0
				$_InOUComputer = "Initialized but no OU available"
			EndIf
		EndIf
	EndIf
	    
EndFunction


Edited by Mart (2009-07-30 11:09 AM)
_________________________
Mart

- Chuck Norris once sold ebay to ebay on ebay.