Page 1 of 1

Copy an AD attribute to another AD attribute

Posted: Thu Jun 28, 2012 4:52 am
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

Copy an AD attribute to another AD attribute

Posted: Thu Jun 28, 2012 5:03 am
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.


Copy an AD attribute to another AD attribute

Posted: Thu Jun 28, 2012 6:27 am
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

Copy an AD attribute to another AD attribute

Posted: Thu Jun 28, 2012 6:55 am
by jvierra
Gets all users.
uploads/2491/GetAllUsers.txt