Active Directory powershell script Display Name issue

Hi Everyone. I have a script which provides me to create bulk of users. Script reads my csv file and fills attributes from this csv. But I have an issue. Display name shows not correct in my AD interface. When I create manually from AD interface it seems ok.
As you see from image user:spashaeyv have displayname but in AD interface it doesn't show it. It shows direct username. How can I solve this issue?

But user Delicatessen which I have created manual seems ok.
amir damirovAsked:
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

x
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

footechCommented:
You would have to provide your script to troubleshoot.
0
J SSenior Systems AdministratorCommented:
Just based on reading what your experiencing I'd say your script needs to assign the displayname based on the Firstname csv value.
0
J SSenior Systems AdministratorCommented:
Another thought is if that doesnt work, is to create your users, then run an additional set-aduser -displayname either after create or in another loop
0
Simplify Active Directory Administration

Administration of Active Directory does not have to be hard.  Too often what should be a simple task is made more difficult than it needs to be.The solution?  Hyena from SystemTools Software.  With ease-of-use as well as powerful importing and bulk updating capabilities.

Shaun VermaakTechnical SpecialistCommented:
That is not the display name, that is the cn. Change script to set the same value to the cn that is assigned to display name
1
amir damirovAuthor Commented:
Dear All, thank you for the replies. Here is my script

bulk-of-users.JPG
Dear Shaun,

I've tried to assign value to the "cn" as you wrote. But for the "New-ADuser" command there is no such key "cn". I couldnt find it.
cn.JPG
0
Shaun VermaakTechnical SpecialistCommented:
Do a set after
Set-ADUser ($User) -Replace @{ "cn" = "$($User.DisplayName)"}

Open in new window

0
amir damirovAuthor Commented:
Dear Shaun, thank you for reply.

This is my first script expierence in povvershell. Think there is something wrong again. Becasuse i've ran that comman it shows error.script.JPG
0
Shaun VermaakTechnical SpecialistCommented:
Hi Amir

That needs to run within the loop. So in line 19, before the } and a ; and the line I posted
0
amir damirovAuthor Commented:
Hi again and thanks for your help, Shaun. I've tried but the same error ;\

scriptJPG.JPG
0
footechCommented:
What happened to the images in the original question?  With those missing, it makes it much more difficult to see what your issue is.

Sorry to have to contradict the others, but there's no need to set the cn attribute specifically.  I have a script which I use regularly to create users, and it has no such thing.  The cn attribute is populated when you supply information to the -Name parameter of New-ADUser.  If you try to change it with Set-ADUser, you will get an error that says, "The attribute cannot be modified because it is owned by the system".

The script as shown in #a42509183 will not work.  (Side note - it's always best to provide your code as text within a code block, rather than an image, so that others can easily copy it and test).  The code as shown will display errors because of the way you've broken up the (single) command into multiple lines without using a line continuation character.  If I fix it to run without error, then the DisplayName is filled correctly.

Provide your images again, and a sample input .CSV with which you can duplicate what you are seeing.  It's possible there's a format issue with your .CSV that's causing the issue.
0
Shaun VermaakTechnical SpecialistCommented:
Please post the whole script as is
0
amir damirovAuthor Commented:
Thank you, again.  Here is my code below. There is no issue with CSV file. Because below code works fine.

So I need just correct display name for users.

I can provide CSV file, too.

$Password = Read-Host "Enter the password that you want to set" -AsSecureString

$Users= Import-Csv 'C:\Bulk of users.csv'


$users | ForEach-Object {mkdir($_.’HomeDirectory’)}


foreach($User in $Users){New-ADUser -Name $User.LoginName -Title $user.Title -PostalCode $user.Postal -Country $User.Country -office $User.office -city $User.city -Surname $User.LastName -State $User.State -GivenName $User.Firstname -SamAccountName $User.LoginName -userPrincipalName $User.PrincipalName -Department $User.Department -Company $User.Company -AccountPassword $Password -DisplayName $User.DisplayName -HomeDirectory $User.HomeDirectory -HomeDrive $User.HomeDrive -Path "OU=Users,OU=1000,OU=Markets A, DC=firstit, DC=az" -Enabled $true -Passthru }

Open in new window

Bulk-of-users.csv
0
footechCommented:
Where's the issue?  Using your example shows the display name fine for me.
 sample userDo you see something different?

If you're talking about what's displayed in the red box, if you want that to be the same as the Display Name, then you need to change what you supply to the -Name parameter for New-ADUser.  Like
New-ADUser -Name $User.DisplayName
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
amir damirovAuthor Commented:
Dear All, thank you for your response.
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Powershell

From novice to tech pro — start learning today.