Copy an AD attribute to another AD attribute

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.
This topic is 11 years and 8 months old and has exceeded the time allowed for comments. Please begin a new topic or use the search feature to find a similar but newer topic.
Locked
User avatar
mylastknight
Posts: 1
Last visit: Thu Jun 28, 2012 4:52 am

Copy an AD attribute to another AD attribute

Post by mylastknight »

Does anyone have an example script that copies an AD Attribute to another Attribute and will do this for all objects in AD? I would also like the changeds output to a log file.

Specifically, I need to copy the ipphone attribute to extensionAttribute 12 for all users and log the output to a file. I would be greatful!!!!

Jamesmylastknight2012-06-28 11:55:19
jvierra
Posts: 15439
Last visit: Tue Nov 21, 2023 6:37 pm
Answers: 30
Has voted: 4 times
Been upvoted: 33 times

Copy an AD attribute to another AD attribute

Post by jvierra »

What are ALL OBJECTS? Do you want to copy all object properties to all object properties. That doesn't make any sense. All objects do not have the same attributes. Example: An OU soes not have a phone number or email address.

jvierra
Posts: 15439
Last visit: Tue Nov 21, 2023 6:37 pm
Answers: 30
Has voted: 4 times
Been upvoted: 33 times

Copy an AD attribute to another AD attribute

Post by jvierra »

It just takes three lines.

set user = GetUser(LDAP://cn=user1,dc=serv,dc=dom,dc=com)
user.extensionAttribute12=user.ipphone
user.Setinfo


Just get all users and feed them to the code above.

Code: Select all

set OU =GetObject("LDAP://cn=users,dc=domain,dc=local")
OU.Filter="objectClass=user"
For each user in OU
    If user.class="user" Then
        On Error Resume Next
        user.extensionAttribute1=user.ipphone
        If Err.Number = 0 Then
             user.SetInfo
             WScript.Echo "Copied:" & user.ipphone & " for " & user.name 
        Else
             On Error GoTo 0
             WScript.Echo "No IPPHONE configured for " & user.name
        End If
        On Error GoTo 0
    End If
next
jvierra
Posts: 15439
Last visit: Tue Nov 21, 2023 6:37 pm
Answers: 30
Has voted: 4 times
Been upvoted: 33 times

Copy an AD attribute to another AD attribute

Post by jvierra »

Gets all users.
uploads/2491/GetAllUsers.txt
This topic is 11 years and 8 months old and has exceeded the time allowed for comments. Please begin a new topic or use the search feature to find a similar but newer topic.
Locked