Freshen Up Your Users: Adding Data to Active Directory User Objects
Ok. Here’s another niche one. Imagine this: you inherit a bland Active Directory. Those who came before neglected to add in details such as phone numbers, department, job title, etc, and you don’t have fancy on-boarding software.
Let’s figure out a way to update the properties of AD Users en masse with PowerShell.
Do the Grunt Work First
This part kind of sucks. You’ll have to compile a .csv file including the data you want to input. I lucked out when another department had most of the data I was looking for, but you may have to manually create the table. I set my .csv file up like this:

The most important information you need is the User Principal Name. I always key off of the UPN as this is stagnant with the identity of the user (in most cases).
Note: you can use the following command to pull a list of ALL of the properties for ALL of your AD users. Replace the second ” * ” with the properties you’re looking for.
get-aduser -filter * -Properties * | Export-Csv "<path>\<filename>.csv"
Now, I usually build off this exported .csv file with the information I want to add. In this case, let’s add data to the department field.
Check out the script below.
Import-Csv -Path '<path>\<filename>.csv' | ForEach-Object {
$userPrincipalName = $_.UserPrincipalName
$newDepartment = $_.Department
$adUser = Get-ADUser -Filter "UserPrincipalName -eq '$userPrincipalName'" -Properties Department
if ($adUser) {
Set-ADUser -Identity $adUser.DistinguishedName -Department $newDepartment
Write-Host "Will update $userPrincipalName to Department '$newDepartment'"
} else {
Write-Warning "User $userPrincipalName not found in AD."
}
}
This will effectively scroll through the UserPrincipalNames that you’ve included in your .CSV file and apply the new information.
There are a plethora of properties that you can modify this way, just use intellisense (CTRL + Space) to check out which flags you can use.

There’s a bunch of possibilities for what you can update with Set-ADUser, and you can use this to populate properties such as Manager, Company, PhoneNumber and more! Note: if you populate the manager, you can start building up an org chart that populates in Outlook and Teams. (See the full script on GitHub to see how I did it with an additional Get-ADUser cmd.)
As always:
This project is provided “as is” without any warranty of any kind, express or implied. Use it at your own risk. The authors and contributors are not responsible for any damage, data loss, or other issues that may arise from using this software. You are solely responsible for any actions taken based on this code.