1.Enabel windows feature
Makes sure you have already install the Set-AdAccountPassword feature, or install it by follows
-
Win10 download&install: https://www.microsoft.com/en-au/download/details.aspx?id=45520
-
Windows Server:
Import-Module ServerManager
2.Run script
Create file: .\change_password.ps1
param (
[string]$domain = "domain",
[string]$userName = "account",
[string]$oldPassword = "old_password",
[string]$newPassword = "new_password"
)
sleep 10
$SeOldPassword = ConvertTo-SecureString -AsPlainText $oldPassword -Force
$SeNewPassword = ConvertTo-SecureString -AsPlainText $newPassword -Force
$Credential = New-Object System.Management.Automation.PSCredential ("$domain\$userName", $SeOldPassword)
#gwmi win32_service -credential $MySecureCreds -computer PC#
Set-AdAccountPassword -Credential $Credential -Server $domain -Identity $userName -OldPassword $SeOldPassword -NewPassword $SeNewPassword
Then run command:
.\change_password.ps1 {yourDomain} {yourAccount} {yourOldPassword} {yourNewPassword}
Leave a Reply