Edit MSOL user details using CSV and Powershell


This script is used to edit the multiple user parameters at once using CSV file and Powershell

For Example:

A office365 tenant has 1000's of user and you need to update their usage location their title.

You need to create a CSV file which contain the following columns  

-UPN of the user of whom you want to edit the details

-Usage Location: New usage Location

-Title: New title  


Install-Module -Name Msonline


Import-Csv -Path "C:\Users\Awais\Desktop\Details.csv" | foreach {

$users = get-msoluser | select userprincipalname,objectid | where {-userprincipalname -like $_.UPN }

Set-Msoluser  -UserPrincipalName $_.UPN -UsageLocation "IE" -Title “Driver” -ObjectId (Get-MsolUser -UserPrincipalName $_.UPN).objectid}


If you want to edit all users

Import-Csv "C:\Users\Awais\Desktop\Faculty.csv" | ForEach-Object { Set-MsolUser -userPrincipalName $_.UserPrincipalName -Title $_.Jobprofile}

Did this answer your question? Thanks for the feedback There was a problem submitting your feedback. Please try again later.

Still need help? Contact Us Contact Us