Back to blog

Update Office 365 User Details From A CSV File

Aug 21, 2012 by Emma Robinson

I came across a great question in the Office 365 community forums the other day asking for help with updating a large batch of user attributes in Office 365. The person wanted to update the Company, Title, Department, and Office of a selection of users using information in a CSV file.

Here is an example CSV file template you could use for this. The login name fields needs to match the Office 365 login address (Also known as UserPrincipalName)

login_name,company,title,department,office,Cogmotive Reports,Sales Manager,Sales,London,Cogmotive Reports,Operations Manager,Operations,London,Cogmotive Reports,Network Janitor,Networking,San Francisco

Read moreĀ Optimizing PowerShell for large Office 365 tenants

Once you have connected to Office 365 using Powershell, you need to import the CSV file into a variable called $user_file using this command.

PS C:\scripts\>$user_file = Import-CSV c:\scripts\users.csv

Once you have this variable configured, you can run the following command to update all the users.

PS C:\scripts\>$user_file | ForEach {Set-user $_.login_name -Company $ -Title $_.title -Department $_.department -Office $}

Click here if you would like to learn more about our Office 365 Management Software.