在 Microsoft 365 中用於設定 Office 應用程式、兌換產品金鑰和啟動授權的流程。
Dear Mr Lo Yun Lung
Thank you for posting in the Microsoft Community. We are happy to provide you with help.
Please note that our team will respond to your inquiry in English, you can publish your response in your native language and we will translate it in-house. Thank you for your understanding.
Based on the screenshot shared the error message is due to null instance in each loop, the Azure AD is not able to identify objects to commit new changes to.
Please check if running the following command returns any result before executing for each loop, and check to see if any error is presented. ( You may share screenshots here of your tests).
Get-MsolUser -UserPrincipalName ******@domain.com
I'd also like to confirm if the initial users have been created already and only new information is being added? If not then please try to run : New-MsolUser
The above command is to be run only if users haven't already been created, if that’s not the case please skip this step no need to run that command.
Lastly please run the following command and share results with us :
$users = Import-Csv C:\Temp\o365f1student.csv
Foreach($user in $users){ Set-MsolUser -UserPrincipalName $user. UserPrincipalName -DisplayName $user. DisplayName }
Please understand that sometimes our first answer may not solve the problem right away. It depends on what information we get in the thread and the complexity of the question. But through your cooperation, we can find a solution together.
We look forward to hearing from you.
In good faith
Momo | Microsoft Community Moderator
Dear Mr Lo Yun Lung
Thank you for posting in the Microsoft Community. We are happy to provide you with help.
Based on the screenshot from the share, the error message is that Azure AD does not recognize the object to commit the new changes to because of an empty instance in each loop.
Before executing each loop, check to see if running the following command returns any results and check for any errors. (You can share a screenshot of the test here).
***Get-MsolUser -UserPrincipalName ***@domain.com
I also want to confirm that the initial user has been created and only new information has been added? If not, try running: New-MsolUser
Run the above command only if the user has not been created, if this is not the case, skip this step and do not need to run the command.
Finally, please run the following command and share the results with us:
$users = Import-Csv C:\Temp\o365f1student.csv
Foreach($user in $users){ Set-MsolUser -UserPrincipalName $user. UserPrincipalName -DisplayName $user. DisplayName }
Please understand that sometimes our first answer may not solve the problem immediately. It depends on the information we get in the thread and the complexity of the problem. But through your cooperation, we can find solutions together.
We look forward to hearing from you.
In good faith
Momo | Microsoft Community Moderator