move user based on Attribute - help

Anything VBScript-related, including Windows Script Host, WMI, ADSI, and more.
Forum rules
Do not post any licensing information in this forum.

Any code longer than three lines should be added as code using the 'Select Code' dropdown menu or attached as a file.
Locked
User avatar
matrix101
Posts: 7
Meble kuchenne na zamówienie - na wymiar - Wrocław
Joined: Thu Jun 07, 2007 4:29 am

move user based on Attribute - help

Post by matrix101 »

hi all,

I have found this script and it works - moving users from one OU to another OU.

Question = how can I modify it to only move users who have attribute "company=2" only. Thank you apprepricate the help as I'm new to scripting.

**************Set objNewOU = GetObject("LDAP://ou=qdobaemp,ou=users,ou=managed objects,dc=testcorp,dc=testjack,dc=net")Set objOldOU = GetObject("LDAP://ou=clan,ou=users,ou=managed objects,dc=testcorp,dc=test,dc=net")
objOldOU.Filter = Array("user")
For Each objUser in objOldOU objNewOU.MoveHere objUser.ADsPath, vbNullString Next
end if

User avatar
matrix101
Posts: 7
Joined: Thu Jun 07, 2007 4:29 am

move user based on Attribute - help

Post by matrix101 »

hi all,

I have found this script and it works - moving users from one OU to another OU.

Question = how can I modify it to only move users who have attribute "company=2" only. Thank you apprepricate the help as I'm new to scripting.

**************Set objNewOU = GetObject("LDAP://ou=qdobaemp,ou=users,ou=managed objects,dc=testcorp,dc=testjack,dc=net")Set objOldOU = GetObject("LDAP://ou=clan,ou=users,ou=managed objects,dc=testcorp,dc=test,dc=net")
objOldOU.Filter = Array("user")
For Each objUser in objOldOU objNewOU.MoveHere objUser.ADsPath, vbNullString Next
end if

jvierra
Posts: 14358
Joined: Tue May 22, 2007 9:57 am
Contact:

move user based on Attribute - help

Post by jvierra »

If objUser.Company = 2 Then
' move
End If

Locked