How to reset password through Powershell

Configurare noua (How To)

Situatie

Resetting a password through PowerShell typically involves interacting with the Active Directory module. If you are working in a Windows environment with Active Directory, you can use PowerShell cmdlets to reset a user’s password.

Solutie

Open PowerShell with Administrative privileges:

    • Right-click on the PowerShell icon and select “Run as Administrator”

Import the Active Directory module:

    • If you are using Windows Server 2012 or later, the Active Directory module should be available. Import it with the following command:

Import-Module ActiveDirectory

Reset the password:

  • Use the Set-ADAccountPassword cmdlet to reset the password. Replace username with the actual username, and newpassword with the desired new password.
Set-ADAccountPassword -Identity username -NewPassword (ConvertTo-SecureString -AsPlainText “newpassword” -Force) -Reset

Force the user to change the password at next logon (optional):

  • If you want to ensure that the user changes their password at the next logon, you can use the Set-AdUser cmdlet:

Set-AdUser -Identity username -ChangePasswordAtLogon $true

  • This step is optional and depends on your organization’s policies.

Verify the password reset:

    • You might want to verify that the password has been reset successfully. You can use the Get-ADUser cmdlet to check the PasswordLastSet property:
Get-ADUser -Identity username | Select-Object Name, PasswordLastSet

Remember to replace username and newpassword with the actual username and the desired new password. Additionally, ensure that you have the necessary permissions to reset passwords in Active Directory.

Tip solutie

Permanent

Voteaza

(4 din 11 persoane apreciaza acest articol)

Despre Autor

Leave A Comment?