Office 365 - trying to bulk update users in powershell from CSV

Copper Contributor

Can someone check this? I am trying to update multiple users via CSV. I am connected to the MsolService and using set-user to change the mentioned paramaters, and Im getting the error "Set-User : A parameter cannot be found that matches parameter name 'Jobtitle', and etc. for each field. Am i using set-user correctly? I am using this string:

 

$user_file = import-CSV "CSVfilepathhere.csv"

 

$user_file | ForEach-Object {Set-user -identity $_.userprincipalname -Jobtitle $_.jobtitle -usagelocation $_.usagelocation -country $_.country -officeLocation $_.officeLocation}

 

1 Reply
try this

Import-Csv C:\M365\users.csv | foreach{Set-MsolUser -UserPrincipalName $_.UserPrincipalName -DisplayName $_.DisplayName -FirstName $_.FirstName -LastName $_.LastName -City $_.City -StreetAddress $_.StreetAddress -Department $_.Department -Country $_.Country -MobilePhone $_.MobilePhone}