Chat with us, powered by LiveChat

Blog

Back

Update Office 365 User Details From A CSV File

21 Aug 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
user1@cogmotive.com,Cogmotive Reports,Sales Manager,Sales,London
user2@cogmotive.com,Cogmotive Reports,Operations Manager,Operations,London
user3@cogmotive.com,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 $_.company -Title $_.title -Department $_.department -Office $_.office}