[PowerShell/Microsoft.Graph] Reset User Password

Kevin Nguyen 101 Reputation points
2022-08-03T11:02:58.71+00:00

Hi, I'm trying to reset an user password with powershell using the Microsoft Graph Module.

I'm connecting to the graph with this cmd, with all the Certificate stuff :

Connect-MgGraph -ClientId $clientId -TenantId $tenantId -CertificateThumbprint $certThumbprint

Following this article https://mikecrowley.us/2022/03/24/resetting-azure-ad-user-passwords-with-microsoft-graph-powershell/, I tried to use the cmdlet : Reset-MgUserAuthenticationMethodPassword

Unfortunately the error is
227578-screenshot-1.png

From other questions, such as : resetting-a-users-password or how-to-update-the-password-of-user-in-azure-ad-using-graph-api, I should give the permission : Directory.AccessAsUser.All and use the cmdlet Update-MgUser but I still got an error :

227673-screenshot-3.png

Here are my permissions :

227670-screenshot-2.png

And here are the Permission/Scopes from the context :

![227675-screenshot-4.png]7

Am I missing something ?

Thanks.

Windows for business Windows Server User experience PowerShell
Microsoft Security Microsoft Graph
0 comments No comments
{count} votes

Accepted answer
  1. Vasil Michev 119.5K Reputation points MVP Volunteer Moderator
    2022-08-03T13:38:55.21+00:00

    Directory.AccessAsUser.All is a delegate permission, it requires you to connect in the user context, whereas your Connect-MgGraph cmdlet uses CBA/application login. This is also the reason why you don't see the Directory.AccessAsUser.All scope listed in the output of Get-MgContext.

    Application permissions are not supported for the password reset operation, as mentioned in the official documentation. So, connect in the user context, with an user that has sufficient permissions, and the query should work fine.


0 additional answers

Sort by: Most helpful

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.