Asked by:
azure ad and reset password for user

Question
-
hello,
is it possible to change a user's password in azure ad true powershell?
i use the azure cloud shell and i want to know witch command's i must use if it is possible.
thanx
Tuesday, September 3, 2019 12:36 PM
All replies
-
Hi,
take a look into the following article:
By setting the Password don´t forget to use secure string, otherwise you will run into an error.
e.g.:
-Password (ConvertTo-SecureString -String "USER-PASSWORD" -Force –AsPlainText)
regards, pat
- Proposed as answer by [p.sc] Tuesday, September 3, 2019 1:40 PM
Tuesday, September 3, 2019 12:49 PM -
hello,
thank you but when i put in:
Set-AzureADUserPassword -ObjectId "**************" -Password $Hello12345
i get:
Set-AzureADUserPassword : Cannot bind argument to parameter 'Password' because it is null.
Can you give me an example how to?
greetings, martijn
Tuesday, September 3, 2019 1:05 PM -
here an example for an oneliner as in a single case:
Set-AzureADUserPassword -password (ConvertTo-SecureString -String "USER-PASSWORD" -Force –AsPlainText)
For script-use you can do for example this:
$Password = (ConvertTo-SecureString -String "USER-PASSWORD" -Force –AsPlainText)
Set-AzureADUserPassword -password $password
regards, pat
- Proposed as answer by [p.sc] Tuesday, September 3, 2019 1:40 PM
Tuesday, September 3, 2019 1:36 PM -
Hi,
Was your issue resolved?
If you resolved it using our solution, please "mark it as answer" to help other community members find the helpful reply quickly.
If you resolve it using your own solution, please share your experience and solution here. It will be very beneficial for other community members who have similar questions.
If no, please reply and tell us the current situation in order to provide further help.
Best Regards,
Lee
Just do it.
Wednesday, September 4, 2019 11:23 AM -
1 made a script with:
#Collect details of the User for whom password to be reset
$Username = Read-Host -Prompt "Enter the username"
#Convert the default password to a Secure String
$SecPaswd = "Password" | ConvertTo-SecureString -AsPlainText -Force
#Reset the Password
Set-AzureADUserPassword -ObjectId "$Username@domain.com" -Password $SecPaswd -ForceChangePasswordNextLogin $truebut after i put in the user name then i get the error:
Set-AzureADUserPassword -ObjectId "$Username@domainname.com" -Passwo ...
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : NotSpecified: (:) [Set-AzureADUserPassword], ApiException
+ FullyQualifiedErrorId : Microsoft.Open.AzureAD16.Client.ApiException,Microsoft.Open.AzureAD16.Graph.PowerShell.Custom.Cmdlet.SetUserPassworddo you know what is the problem?
thx
Thursday, September 5, 2019 9:20 AM -
Hi,
Thanks for your response.
-ObjectId: Specifies the ID of an object.
Please use object ID to replace "$Username@domain.com" . But I found in "get-azureaduser" cmdlet -objectid can accept upn.
https://docs.microsoft.com/en-us/powershell/module/azuread/get-azureaduser?view=azureadps-2.0
Best regards,
Just do it.
Thursday, September 5, 2019 9:47 AM -
thx, but is it anyway possible to change an azure ad password using powershell?
i cant get it working:(
thank you
- Edited by XPS M1730 Wednesday, September 11, 2019 8:25 AM
Wednesday, September 11, 2019 8:21 AM -
Hi,
Thanks for your response.
Yes, you can do it. Have you tried my suggestion?
If it also not work, please try to post your error infor for better help.
Best regards,
Lee
Just do it.
Wednesday, September 11, 2019 8:41 AM -
hello
1. Please use object ID to replace "$Username@domain.com" :
i use:
Set-AzureADUserPassword -ObjectId "$Username@domainname" -Password $SecPaswd -ForceChangePasswordNextLogin $true
and i put in the Object id but it still won't work
did i do something wrong?
----------------------------------------------------------------------------
- Edited by XPS M1730 Wednesday, September 11, 2019 8:49 AM
Wednesday, September 11, 2019 8:47 AM -
hello,
i cant get it working, can someone please give me a script how to reset an user password in azure ad?
thanx a lot
Monday, September 16, 2019 10:56 AM -
Please learn to read the help before getting stuck.
\_(ツ)_/
- Proposed as answer by LeeSeenLiMicrosoft contingent staff Friday, October 4, 2019 8:53 AM
Monday, September 16, 2019 11:00 AM