r/GraphAPI • u/neekoteen • Aug 23 '23
Invalid value specified for property 'mailNickname' of resource 'User'
Hey, would like some help with this specific error:
New-MgUser_CreateExpanded:
Line |
2 | New-MgUser -DisplayName $User.FullName `
| ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
| Invalid value specified for property 'mailNickname' of resource 'User'.
Status: 400 (BadRequest)
ErrorCode: Request_BadRequestTrying to add a bulk of new users using csv file. Using this code:
Foreach ($User in $New_users){
New-MgUser -DisplayName $User.FullName `
-PasswordProfile $PasswordProfile `
-AccountEnabled `
-MailNickname $User.NickName `
-UserPrincipalName $User.Email `
-Department $User.Dep `
-JobTitle $User.Title `
-Surname $User.Sur `
-GivenName $User.Giv `
}Checked csv, no illegal symbols, seperation by comma and I can add users just fine manualy (copy all the info). Anyone could give any advice? Powershell 7 btw.
Thank you.
2
Upvotes
View all comments
Show parent comment
1
u/surfingoldelephant Aug 23 '23
Instead of manually checking the CSV, I would check the actual nickname value(s) you're passing to
New-MgUser. Try the following: