[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.

Microsoft Graph
Microsoft Graph
A Microsoft programmability model that exposes REST APIs and client libraries to access data on Microsoft 365 services.
10,716 questions
Windows Server PowerShell
Windows Server PowerShell
Windows Server: A family of Microsoft server operating systems that support enterprise-level management, data storage, applications, and communications.PowerShell: A family of Microsoft task automation and configuration management frameworks consisting of a command-line shell and associated scripting language.
5,389 questions
0 comments No comments
{count} votes

Accepted answer
  1. Vasil Michev 96,076 Reputation points MVP
    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