Update user information via PowerShell

ruchi9 20 Reputation points
2024-02-19T08:40:10.57+00:00

Hello, Trying to update bulk users information via below powershell. $users = Import-Csv -Path "C:\usersinfo.csv" foreach ($user in $users) { $userPrincipalName = $user.username $employeeId = $user.EmployeeId $hiredate = $user.EmployeeHireDate Set-AzADUser -EmployeeId $employeeId -ObjectId $userPrincipalName -EmployeeHireDate $hiredate } getting error
Az.MSGraph.internal\Update-AzADUser : Unable to update the specified properties for on-premises mastered Directory Sync objects or objects currently undergoing migration. An error occurred when trying to update both cloud and on-premise users. I am curious if there is a command that can update the information of both cloud and on-premise users. Thanks in advance.

Microsoft Entra
Microsoft Entra ID
Microsoft Entra ID
A Microsoft Entra identity service that provides identity management and access control capabilities. Replaces Azure Active Directory.
23,816 questions
{count} votes

Accepted answer
  1. Navya 16,775 Reputation points Microsoft External Staff
    2024-02-19T09:15:49.25+00:00

    Hi @ruchi9

    Thank you for posting this in Microsoft Q&A.

    I understand you want to update cloud and on-premises user's information via PowerShell, and you are curious if there is a command that can update the information of both cloud and on-premises users.

    Unfortunately, there is no command to update both cloud and on-premises user's information. Users synced from on-premises Active Directory can only be managed in on-premises Active Directory.

    Hope this helps. Do let us know if you any further queries.

    Thanks,

    Navya.

    Please remember to "Accept Answer" if answer helped you. This will help us as well as others in the community who might be researching similar questions.

    1 person found this answer helpful.
    0 comments No comments

1 additional answer

Sort by: Most helpful
  1. Luis Arias 8,026 Reputation points
    2024-02-19T09:23:52.4666667+00:00

    Hi ruchi9,

    This error message appear when try to update properties for users sync by on-premises in that case the best option is update thes users in onpremise and force sync the values to azure:

    1. Update Onprem: https://learn.microsoft.com/en-us/powershell/module/activedirectory/set-aduser?view=windowsserver2022-ps
    2. Sync: https://techcommunity.microsoft.com/t5/itops-talk-blog/powershell-basics-how-to-force-azuread-connect-to-sync/ba-p/887043

    If the answer help you to address your issue, accept the response.

    Luis

    0 comments No comments

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.