Powershell script to add attributes of AD users

I have another question open, in regards to updating user account information in a Win 2008 environment, but I believe it will not work until I add some necessary attributes. Most users on our AD network were imported with the bare minimum of attributes configured. I need to add the full UPN in the Account settings tab (see screen shot). At this time, only the [pre-windows-2000] info is present. This is a federated domain and setting the UPN suffix is easily done via user properties, but I also need the logon name field populated for about 1500 users.
Screenshot-7.png
tamray_techAsked:
Who is Participating?
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.

NumbidCommented:
You can use a tool like ADModify.NET to make bulk changes to your active directory.

You can use variables to populate fields with existing values, concatenate text, etc.

0
SubsunCommented:
To set UPN for single user we can use..
Set-ADUser User -UserPrincipalName User@domain.com

Open in new window


Bulk modification is depends on your input.. if you have a text file of all users samaccountname and your domain name is same then you can try..
GC User.txt | % {Set-ADUser $_ -UserPrincipalName "$_@domain.com"}

Open in new window

input file format..
UserA
UserB
UserC

Open in new window

0
tamray_techAuthor Commented:
That is the dilemma... None of these current users show anything in the logon name, which I need to be there in order to change the other attributes. We do not have a text file containing all the users sam accounts either and recreating them one by one is not practical. However, the user does show up in account settings under [pre-windows-2000]. If I could export that info, I can create the proper csv file to make the rest of the changes.
0
10 Tips to Protect Your Business from Ransomware

Did you know that ransomware is the most widespread, destructive malware in the world today? It accounts for 39% of all security breaches, with ransomware gangsters projected to make $11.5B in profits from online extortion by 2019.

SubsunCommented:
Is this users created in same OU?

are you getting result when you run Get-ADUser agaist the user whcih you posted?
Get-ADUser asomody98

BTB You can use pre Windows 2000 logon name (sAMAccountName) to modify the account..
0
tamray_techAuthor Commented:
That works... I get all the user info
0
SubsunCommented:
Ok.. Is this users created in same OU?
0
tamray_techAuthor Commented:
Ok... I am ready to accept both solutions. Please post your sam account solution here, so I can accept it and I will accept your previous solution on the other question.
0
SubsunCommented:
Put the SamAccountName's in a text file and use the previous code which I posted to modify the UPN. And if you have all the account in on OU and you want modify the all. The you can use this code.. This code will search on "OU=IT,OU=Admin,DC=Domain,DC=com" and update the UPN for all user accounts.. Please let us know if you have any questions..

Get-ADUser -SearchBase "OU=IT,OU=Admin,DC=Domain,DC=com" -filter * | % {Set-ADUser $_.SamAccountName -UserPrincipalName "$($_.SamAccountName)@domain.com"}

Open in new window

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
tamray_techAuthor Commented:
Big help!
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.