Adding MsolUser Information with a csv file
-
Wednesday, February 27, 2013 3:13 PM
Hello!
I want to update the Office 365 User information via powershell. I have a .csv with UPN,Title,MobilePhone
It looks like:
UserPrincipalName;Title;MobilePhone;
user1@domain.at;IT First Level Support;+43 664 12345678;
user2@domain.at;IT Infrastruktur indiv. Software;+43 699 12345678;I wrote this command:
import-csv C:\Benutzerdatentest.csv | ForEach {Set-MsolUser -UserPrincipalname -Title $_.Title -MobilePhone $_.MobilePhone}
but it doesn't work.
I want to add/update for each UPN in the .csv the title and MobilePhone information. All users allready exist.
Any idea?
All Replies
-
Wednesday, February 27, 2013 3:24 PMModerator
Hi,
Your csv file is not comma-delimited (,) but semicolon delimited (;). You have to tell import-csv what delimiter you're using if you're not using a comma (-delimiter ';').
Bill
-
Wednesday, February 27, 2013 3:39 PM
I've corrected all ; to ,
Now I get the error: Missing Argument for the parameter "UserPrincipalName" Give a parameter from type "system.string" and try it again. (poorly translated)
-
Wednesday, February 27, 2013 4:01 PMModerator
Take a close look at your command:
import-csv C:\Benutzerdatentest.csv | ForEach-Object { Set-MsolUser -UserPrincipalName -Title $_.Title -MobilePhone $_.MobilePhone }
I bolded and underlined the relevant portion. Note that the -UserPrincipalName parameter you are using for Set-MsolUser is missing an argument.
Thus your command should be:
import-csv C:\Benutzerdatentest.csv | ForEach-Object { Set-MsolUser -UserPrincipalName $_.UserPrincipalName -Title $_.Title -MobilePhone $_.MobilePhone }
Bill
-
Wednesday, February 27, 2013 4:37 PM
Now getting:
Set-MsolUser : You have to enter a required property: Parametername : ObjectId Bei Zeile:1 Zeichen:94 + import-csv C:\Benutzerdatentest.csv | ForEach-Obje ct {Set-MsolUser <<<< -UserPrincipalName $_.UserPrincipalName -Title $_.Title -MobilePhone $_.MobilePhone} + CategoryInfo : OperationStopped: (:) [Set-MsolUser], MicrosoftO nlineException + FullyQualifiedErrorId : Microsoft.Online.Administration.Automation.Requi redPropertyNotSetException,Microsoft.Online.Administration.Automation.SetU serwhich ObjectID does it mean? Isn't it UPN? Still not working.
Thanks for your help so far.
-
Wednesday, February 27, 2013 4:42 PMModerator
Hi,
Sorry, but that's as far as I can help as I don't use or have access to Office 365.
Bill
-
Friday, March 01, 2013 9:39 AM
Finally got it!
The real Problem was the .csv. After i removed the last comma in the CSV-Header it worked.
Here is what it looked like:
UserPrincipalName,Title,MobilePhone
user1@domain.at,IT First Level Support,+43 664 12345678,
user2@domain.at,IT Infrastruktur indiv. Software,+43 699 12345678,Then the following PS-Command to Update MSOL User Information worked well.
Import-Csv C:\Userupdate.csv | ForEach-Object {Set-MsolUser -UserPrincipalName $_.UserprincipalName -Title $_.Title -MobilePhone $_.MobilePhone}

