Link to home
Start Free TrialLog in
Avatar of tamray_tech
tamray_tech

asked on

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
Avatar of Numbid
Numbid
Flag of France image

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.

Avatar of SubSun
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

Avatar of tamray_tech
tamray_tech

ASKER

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.
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..
That works... I get all the user info
Ok.. Is this users created in same OU?
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.
ASKER CERTIFIED SOLUTION
Avatar of SubSun
SubSun
Flag of India image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Big help!