I managed to write the VBScript which does what I wanted, so I will share it here. The script probably needs a very good cleanup, but for now it does the job so I'm hoping it can help other people too.
' Get OU
strOU1 = "OU=here,DC=mydomain,DC=com"
strOU2 = "OU=there,DC=yourdomain,DC=com"
Dim samid
Dim ldap_command
' Create connection to AD
'
Set objConnection = CreateObject("ADODB.Connection")
objConnection.Open "Provider=ADsDSOObject;"
' Create command
'
Set objCommand1 = CreateObject("ADODB.Command")
objCommand1.ActiveConnection = objConnection
objCommand1.Properties("Page Size") = 1000
' Execute command to get all users in OU
'
objCommand1.CommandText = _
"<LDAP://" & strOU1 & ">;" & _
"(&(objectclass=user)(objectcategory=person));" & _
"adspath,distinguishedname,sAMAccountName;subtree"
Set objRecordSet = objCommand1.Execute
' Show info for each user in OU
'
Do Until objRecordSet.EOF
' Show required info for a user
'
samid = objRecordSet.Fields("sAMAccountName").Value
WScript.Echo "Processing " & objRecordSet.Fields("sAMAccountName").Value
Set objCommand2 = CreateObject("ADODB.Command")
ldap_command = _
"<LDAP://" & strOU2 & ">;" & _
"(&(objectclass=user)(objectcategory=person)" & _
"(sAMAccountName=" & samid & "));" & _
"adspath,distinguishedname,sAMAccountName;subtree"
objCommand2.CommandText = ldap_command
objCommand2.ActiveConnection = objConnection
objCommand2.Properties("Chase referrals") = &H40
Set objRecordSet2 = objCommand2.Execute
If objRecordSet2.RecordCount = 0 Then
Wscript.Echo "The sAMAccountName is not in use."
Else
Wscript.Echo "This ID is in use"
End If
' Move to the next user
'
objRecordSet.MoveNext
Loop