Update-MgUser giving error "Attempted to perform an unauthorized operation"

Anhvariel 0 Reputation points
2023-03-21T03:45:23.72+00:00

Attempting to update a field (About Me) in an Azure AD user account. I've created an app, attached a certificate and assigned the API permission "Directory.ReadWrite.All". I am able to successfully connect to Graph, read user data, just not update anything, I get the error when running the Update-MgUser command "Attempted to perform an unauthorized operation."

Microsoft Graph
Microsoft Graph
A Microsoft programmability model that exposes REST APIs and client libraries to access data on Microsoft 365 services.
11,842 questions
0 comments No comments
{count} votes

2 answers

Sort by: Most helpful
  1. Shivam Dhiman 6,051 Reputation points
    2023-03-21T06:27:52.63+00:00

    Hi @Anhvariel

    I was able to replicate the same issue. Please Consent Sites.readwrite.all application permission before running this Graph API endpoint. After adding this permission, I got desired result.

    Hope this helps.

    If the answer is helpful, please click Accept Answer and kindly upvote. If you have any further questions about this answer, please click Comment.

    0 comments No comments

  2. Zehui Yao_MSFT 5,856 Reputation points
    2023-03-21T09:10:22.9533333+00:00

    Hi I can use Update-MgUser locally, would you mind more details to help us better solve your problem?

    User's image


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.