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
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.
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.
- mylastknight
- Posts: 1
- Last visit: Thu Jun 28, 2012 4:52 am
Copy an AD attribute to another AD attribute
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
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.
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