Changing user password in Azure AD with MgGraph

bombbe 1,486 Reputation points
2023-10-25T07:20:02.8966667+00:00

Hello,

I'm creating script that get finds wanted service accounts in Azure AD and then changes their password. To find wanted account I'm using following line which works fine

$accounts = Get-MgUser -ConsistencyLevel eventual -Count userCount -Search 'DisplayName:SVC_Acc'


Then I would go to Foreach loop and change all theirs passwords

foreach($account in $accounts) {
$name = $account.DisplayName 
$id = $account.Id  
Write-Output "Account In Azure AD: $name. Changing the password now..."

}

I have now hard time finding the right command in MgGraph which can change users passwords. All I can find is the old AzureAD module which I would not want to use. So are there MgGraph cmdlet for changing user passwords?

#Set-AzureADUserPassword -ObjectId  "$id" -Password $password
Windows for business | Windows Server | User experience | PowerShell
Microsoft Security | Microsoft Entra | Microsoft Entra ID
Microsoft Security | Microsoft Graph
0 comments No comments

2 answers

Sort by: Oldest
  1. Andy David - MVP 160.4K Reputation points MVP Volunteer Moderator
    2023-10-25T11:38:22.6566667+00:00

    Was this answer helpful?


  2. Deleted

    This answer has been deleted due to a violation of our Code of Conduct. The answer was manually reported or identified through automated detection before action was taken. Please refer to our Code of Conduct for more information.


    Comments have been turned off. Learn more

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.