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 Security | Microsoft Graph
0 comments No comments

2 answers

Sort by: Most helpful
  1. Zehui Yao_MSFT 5,806 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

    Was this answer helpful?


  2. Shivam Dhiman 5,936 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.

    Was this answer helpful?

    0 comments No comments

Your answer

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