amir damirov
asked on
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.
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.
You would have to provide your script to troubleshoot.
Just based on reading what your experiencing I'd say your script needs to assign the displayname based on the Firstname csv value.
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
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
ASKER
Do a set after
Set-ADUser ($User) -Replace @{ "cn" = "$($User.DisplayName)"}
ASKER
Hi Amir
That needs to run within the loop. So in line 19, before the } and a ; and the line I posted
That needs to run within the loop. So in line 19, before the } and a ; and the line I posted
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Please post the whole script as is
ASKER
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.
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 }
Bulk-of-users.csv
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Dear All, thank you for your response.