markc56
asked on
Powershell script to change an attribute for all active directory users
I need to create a script that will rename all active directory users attritbute (cn). Just for clarification this is the the CN= of the DistinguishedName field ( I briefly mixed this up). Mainly, I need the command to change this field in AD.
cn, I believe it is stand for Contexts Name.
anyway what changes you would like to make by script?
like add some prefix or change it to match First Name Last Name?
would you please provide some detail regarding on it.
for instance,
you can do
example
get-aduser -id abc | set-aduser -replace @{cn="abc01"}
anyway what changes you would like to make by script?
like add some prefix or change it to match First Name Last Name?
would you please provide some detail regarding on it.
for instance,
you can do
example
get-aduser -id abc | set-aduser -replace @{cn="abc01"}
ASKER
We have a secondary program for ticketing that we need to import users into from AD. In the cn field we not only have a name, but area of work and here is where the problem is. We are using a "/" between areas and the ticketing program will not recognize the "/", so we need to change it to a "-" or "_" which it does recognize.
do you have last name, first name as the CN?
ASKER
Justin: When I tried running the command you listed (get-aduser -id abc | set-aduser -replace @{cn="abc01"}) I found out you cannot make a change. It errors out referencing a system file error. Thanks for help.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
This works exactly as I needed. Thanks!
Ref : http://ss64.com/ps/rename-adobject.html
If you can explain, what modification you need for the name then only we can suggest further.